3 ms·
GraphQL can support arbitrary numbers of fields and arbitrary nesting of relationships. You can do this: { hero { name friends {
by baddox 7y ago
GraphQL can support arbitrary numbers of fields and arbitrary nesting of relationships. You can do this:
{
hero {
name
friends {
name
friends {
name
}
}
}
}
But some clients might only need this:
{
hero {
name
}
}
This is a small example, but it's pretty clear that "always including all fields and nested relationships in every REST API response" is not a viable solution.
(GraphQL examples based on the schema used in the official documentation: https://graphql.org/learn/queries/ https://graphql.org/learn/queries/)
- xrd 7y agoThis is the most important comment in this thread. For more, read this excellent article: https://brandur.org/graphql https://brandur.org/graphql