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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容