Integrating Sequelize with GraphQL
GraphQL offers a few advantages over alternatives such as REST. We can declare data shapes with strong types, associate relational hierarchies, and reduce the number of requests required when querying data.
GraphQL is a query language that is data storage-agnostic. You can associate a GraphQL model with a typical Database Management System (DBMS), or just as an abstraction for model validation and shaping.
Here is an example of a GraphQL schema definition:
type User { name: String! bio: String roles: [Role!]! } type Role { name: String! }
The User
type has three attributes, with the name
and roles
being required (indicated with the exclamation mark), while the bio
definition is an optional string. Within this example, the User
type’s roles attributes will always return an array with zero or more items from the exclamation mark that sits outside of the brackets ([…]!
), and the...