دسته‌بندی نشده

The latest operation sorts of is actually often query, mutation, or membership and you may describes what sort of process you are planning to help you manage

The latest operation sorts of is actually often query, mutation, or membership and you may describes what sort of process you are planning to help you manage

Procedure name#

Thus far, the audience is playing with a beneficial shorthand syntax in which i neglect one another the newest inquire search term together with query name, but in manufacturing applications it’s useful to make use of these and come up with all of our code quicker ambiguous.

The fresh operation method of needs unless you’re utilizing the inquire shorthand syntax, then you can not likewise have a name otherwise varying definitions to suit your procedure.

The latest process name’s a significant and you may specific title to suit your operation. It’s just needed in multiple-procedure data, but their have fun with try encouraged since it is very useful to own debugging and host-side logging. When one thing fails (you notice mistakes in a choice of your system logs, or in new www.sugardaddydates.org/sugar-daddies-usa/il/rockford logs of GraphQL server) it is simpler to select a query in your codebase of the label instead of looking to understand the new material. Look at this same as a features term on the favorite program coding language. Like, within the JavaScript we’re able to works only with anonymous attributes, but when we give a function a name, it’s simpler to song they off, debug the code, and you can record if it is titled. In the sense, GraphQL query and you will mutation brands, along with fragment names, will likely be a helpful debugging tool for the servers side so you can choose some other GraphQL needs.

Variables#

At this point, the audience is creating all of our objections in the ask string. In really programs, the latest arguments so you can industries will be vibrant: Such as, there might be an excellent dropdown that enables you to choose which Celebrity Battles episode you are interested in, or a venture community, or some filter systems.

They wouldn’t be smart to ticket such vibrant arguments directly in the brand new ask sequence, given that up coming our client-side code would need to dynamically influence the brand new ask sequence in the runtime, and you will serialize they on a good GraphQL-particular format. Alternatively, GraphQL provides a first-category answer to basis dynamic thinking out of the query, and you can solution her or him given that a new dictionary. These values are called parameters.

  1. Change the fixed value regarding ask that have $variableName
  2. age as among the variables acknowledged because of the ask
  3. Pass variableName: really worth regarding separate, transport-specific (usually JSON) variables dictionary

Today, inside our customer code, we are able to only violation an alternate changeable in the place of being required to construct an entirely the latest query. This really is along with in general a behavior to have denoting and that objections within inquire are expected become active – we need to not be doing string interpolation to create requests off user-supplied values.

Adjustable definitions#

This new variable meanings is the area that appears such as for example ($episode: Episode) regarding query significantly more than. It really works since the disagreement significance for a purpose in a penned vocabulary. It lists the variables, prefixed by the $ , accompanied by the particular, in this case Event .

Every announced parameters must be possibly scalars, enums, otherwise enter in target items. So if you need certainly to violation an elaborate target to your a industry, you have to know exactly what type in type which fits with the servers. Find out more about enter in object sizes on the Outline page.

Adjustable definitions can be recommended or needed. In case a lot more than, since there isn’t an enthusiastic ! next to the Occurrence style of, it’s elective. However, if the profession you are passing this new changeable with the means a non-null dispute, then the adjustable needs to be necessary also.

To learn more about the brand new sentence structure for these variable definitions, it’s beneficial to learn the GraphQL outline words. This new schema words is told me in more detail toward Outline webpage.

دیدگاهتان را بنویسید