-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

GraphQL Best Practices
By :

In GraphQL, one crucial aspect to keep in mind is that each resolver must provide a response of a specific type. Failure to do so will result in an error being thrown. This type of enforcement mechanism ensures that the data returned by the resolver matches the expected structure defined in the schema.
Let’s examine this small schema to remind ourselves how GraphQL engines process the response:
type Query{ information: Info! } type Info{ lastUpdated: String! messages: [String!]! }
In GraphQL, we can be sure of how the structure of the response will look, without entering the documentation or asking the person who created the schema. What we know from this schema is that the response structure of the Query.information
resolver would be JSON, with the lastUpdated
field that is for sure a String
type, and messages
, which is an array containing String
instances.
What will happen if the backend developer...