Designing Response Types

Have more questions? Submit a request

Let's say we have a basic GraphQL API that defines the following Query type:

This Query.users field makes intuitive sense: if you query it, you get back a list of User objects. However, this return type doesn't provide any insight into the result:
  • If the list is empty, is that because there are zero users, or did an error occur?
  • Even if the list is populated, did the API return all users or just a subset?

To answer questions like these, it's helpful for top-level fields of Query and Mutation to return "wrapper" objects that can include both the operation result and metadata about the operation's execution.

Learn more on the dev docs.

Articles in this section

Was this article helpful?
0 out of 0 found this helpful
Share

Comments

0 comments

Article is closed for comments.