Docs: graphql.org/learn Flashcards
Query and Mutations / Operation name
What is operation name?
Any operation can be prefixed by operation type (query/mutation/subscription) and operation name.
Required in multi-operation documents.
Query and Mutations / Operation name
What are operation types?
- query
- mutation
- subscription
Queries and Mutations / Fragments
Can fragments use variables?
Fragments can access variables declared in the query or mutation.
Query and Mutations / Variables
3 types of variables.
- Scalars
- Enums
- Input types
Query and Mutations / Inline Fragments
What is inline fragment?
It’s a fragment defined withing a query. Used for interfaces and unions.
Queries and Mutations / Inline Fragments
Is it possible to find out the concrete type (when union or interface was used)?
Yes, using meta field like __typename
Schemas and Types / Arguments
Is it correct
type Starship {
id: ID!name: String!
length(unit: LengthUnit! = METER): Float
}
No, only optional arguments can have default values.
Schemas and Types / Scalar Types
Is Date an official scalar type?
No, it has to be implemented as custom scalar type.
Schemas and Types / Lists and Non-Null
Is
myField: null
valid for
myField: [String]!
?
No
Schemas and Types / Interfaces
Do you need to provide interface fields in a type implementing an interface?
Yes.
Schemas and Types / Input Types
Can input type contain a field being a type?
No, it has to be also an input type.
Schemas and Types / Input Types
Can input type fields have arguments?
No.
Validation
Can fragment refer to itself?
No, as this could result in an unbounded result!
Validation
Can we return type without specifying any field?
No, the graph leaves must be scalar type.
Introspection?
Can you ask GraphQL for a schema?
Yes, using __schema query.