Cov txheej txheem:

Kuv yuav pib GraphiQL li cas?
Kuv yuav pib GraphiQL li cas?

Video: Kuv yuav pib GraphiQL li cas?

Video: Kuv yuav pib GraphiQL li cas?
Video: Yog pib tau dua tshiab - Sua Vaj 2024, Hlis ntuj nqeg
Anonim

Yuav siv li cas GraphiQL . Thaum qhov kev txhim kho server tab tom khiav rau ib qho ntawm koj qhov chaw Gatsby, qhib GraphiQL ntawm https://localhost:8000/_graphql thiab ua si nrog koj cov ntaub ntawv! Nias Ctrl + Chaw (los yog siv ua haujlwm + Chaw ua lwm yam keyboard shortcut) coj mus rau lub qhov rais autocomplete thiab Ctrl + Enter los khiav lub GraphQL nug.

Ib yam li ntawd, nws tau nug, Kuv yuav pib nrog GraphQL li cas?

To-do lis

  1. Xaiv lub moj khaum los siv koj lub GraphQL server. Peb yuav siv Express.
  2. Txhais schema yog li GraphQL paub yuav ua li cas rau cov lus nug tuaj.
  3. Tsim cov kev daws teeb meem uas daws cov lus nug thiab qhia GraphQL dab tsi rov qab los.
  4. Tsim qhov kawg.
  5. Sau cov lus nug ntawm tus neeg siv khoom uas khaws cov ntaub ntawv.

Ib yam li ntawd, koj tsim cov lus nug hauv GraphQL li cas? Cia peb tsim ib daim ntawv thov yooj yim kom nkag siab cov lus nug sib txawv.

  1. Kauj ruam 1 - Kho cov ntaub ntawv Schema. Ntxiv ib sayHello teb uas siv cov hlua parameter thiab rov qab ib txoj hlua.
  2. Kauj ruam 2 - Kho kom raug neeg daws teeb meem. js File.
  3. Kauj Ruam 3 - Tshaj Tawm Cov Lus Nug Sib txawv hauv GraphiQL. Qhov sib txawv tau tshaj tawm nrog $ ua raws li lub npe ntawm qhov sib txawv.

Tom qab ntawd, GraphQL yog dab tsi thiab koj siv nws li cas?

Nyob rau hauv ib tug nutshell, GraphQL yog ib qho syntax uas piav qhia txog yuav ua li cas thov cov ntaub ntawv, thiab feem ntau yog siv los thauj cov ntaub ntawv los ntawm server mus rau tus neeg siv khoom. GraphQL muaj peb yam tseem ceeb: Nws cia tus neeg siv khoom qhia raws nraim li cov ntaub ntawv nws xav tau. Nws ua rau nws yooj yim dua los sau cov ntaub ntawv los ntawm ntau qhov chaw.

Yuav ua li cas koj hla cov lus nug sib txawv hauv GraphiQL?

GraphQL cov lus qhia ceev: Yuav ua li cas dhau qhov hloov pauv hauv GraphiQL

  1. mutation rau tsim cov neeg siv nrog inline sib cav. Hloov pauv hauv GraphiQL.
  2. mutation rau tsim cov neeg siv nrog variables. Yog tias peb xav siv cov kev hloov pauv hauv GraphiQL tsuas yog nyem rau ntawm QUERY VARIABLES vaj huam sib luag hauv qab ntawm koj lub vijtsam thiab dhau cov cai hauv qab no.
  3. piv txwv ntawm JSON nrog hloov pauv.

Pom zoo: