GraphQL 1 (18.02.2023 3M) Flashcards
What is GraphQL?
GraphQL is a query language for API, and a server-side runtime for executing queries using a type system defined for particular data.
What is requred from implementers in order to create GraphQL service?
A GraphQL service is created by defining types and fields on those types, then providing functions for each field on each type.
What does GraphQL service make when receiving an request?
The service first checks a query to ensure it only refers to the types and fields defined, and then runs the provided functions to produce a result.
Give an example of GraphQL type definition and corresponding methods for querying.
See the picture.
What is the essential thing about GraphQL querying?
At its simplest, GraphQL querying is about asking for specific fields on objects. And this is essential to GraphQL, that you always get back what you requested, and the server knows exactly what fields the client is asking for.
Can you make nested object fields selection in GraphQL query?
Yes. You can do it by making a so-called sub-selection of fields for the nested object. GraphQL queries can traverse related objects and their fields, letting clients fetch lots of related data in one request, instead of making several roundtrips as one would need in a classic REST architecture.
See the example of a nested object sub-selection call.
Does GraphQL have a different syntax for selecting fields of object and for fields of an array of objects?
No. GraphQL queries look the same for both single items or lists of items, however, we know which one to expect based on what is indicated in the schema.