GraphQL - Queries and Mutations

Fields

GraphQL queries look the same for both single items or list of items.

GraphQL - Queries and Mutations_第1张图片

Arguments

In GraphQL, every field and nested object can get its own set of arguments. You can even pass arguments into scalar fields.

GraphQL - Queries and Mutations_第2张图片

Aliases

Alias let you rename the result of a field to anything you want.

GraphQL - Queries and Mutations_第3张图片

Fregments

Fregments let you construct sets of fields, and then include them in queries where you need.

GraphQL - Queries and Mutations_第4张图片

Variables

GraphQL has a first-class way to factor dynamic values out of the query, and pass them as a seperate dictionary.

GraphQL - Queries and Mutations_第5张图片

All declared variables must be either scalars, enums or input object types.
Variable definition can be optional or required. Since there isn't a ! next to the Episode type, it's optional.

GraphQL - Queries and Mutations_第6张图片

Directives

A directive can be attached to a field or fragment inclusion.

GraphQL - Queries and Mutations_第7张图片

The core GraphQL specification includes exactly two directives.

  • @include(if: Boolean)
  • @skip(if: Boolean)

Mutations

GraphQL - Queries and Mutations_第8张图片

The review variable we passed in is an input object type.

While query fields are executed in parallel, mutation fields run in series, on after the other, ensuring that we don't end up with a race condition with ourselves.

Inline Fragments

If you are querying a field that returns a interface or a union type, you will need to use inline fragments to access data on the underlying concrete type.

GraphQL - Queries and Mutations_第9张图片

Meta Fields

GraphQL - Queries and Mutations_第10张图片
"__typename" is an meta field

你可能感兴趣的:(GraphQL - Queries and Mutations)