GraphQL 6 (09.01.2023 M) Flashcards

1
Q

Give an example Mutation type declaration.

A

Mutation declaration starts from “type” keyword followed by “Mutation” followed by the declaration of fields between {}. See the example image.

Declaration of Mutation type is the same as for ordinary objects. And looks like this.

< fieldName >(< comma separated list of < argument > >): < fieldType >

< argument > = < argumentName >: < argumentType > [ = < default value > ]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is scalar types in GraphQL?

A

A GraphQL object type has a name and fields, but at some point, those fields have to resolve to some concrete data. That’s where the scalar types come in: they don’t have any sub-fields and represent the leaves of the query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List out of the box GraphQL scalar types?

A
  • Int: A signed 32‐bit integer.
  • Float: A signed double-precision floating-point value.
  • String: A UTF‐8 character sequence.
  • Boolean: true or false.
  • ID: The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can custom scalar types be defined?

A

Yes. In most GraphQL service implementations, there is also a way to specify custom scalar types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe scalar type definition in schema. What is required from server to be done in order to support custom scalar types?

A
  1. Scalar type definition starts from “scalar” keyword followed by scalar type name.

scalar < scalarTypeName >

  1. It’s up to the implementation to define how that type should be serialized, deserialized, and validated. For example, you could specify that the Date type should always be serialized into an integer timestamp, and your client should know to expect that format for any date fields.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Enumeration Type? Give an example.

A

Enumeration types are a special kind of scalar that is restricted to a particular set of allowed values.

When you provide enum value as an argument it looks like string. Value is key sensitive and by convention they are in all upper-case.

For example:
{
“ep”: “JEDI”
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What kind of types you can define in GraphQL?

A

Object types, scalars, and enums are the only concrete kinds of types you can define.

But you can also create abstract types which are Interfaces and Unions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly