GraphQL - Queries and Mutations

Fields

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

Arguments

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

Aliases

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

Fregments

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

Variables

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

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.

Directives

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

The core GraphQL specification includes exactly two directives.

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

Mutations

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.

Meta Fields

"__typename" is an meta field
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容