Expand description
Draft a ready-to-paste example operation for a matched field.
Everything here is mechanical — the schema already says what the arguments are, what the field returns, and which of that type’s fields are leaves. The rules, and why each one:
- Arguments always become variables. Never inline a literal into the query body; a pasted operation should be parameterized from the start.
- One level of selection, leaves only. A scalar or enum return needs no
selection set at all. An object return gets its scalar/enum fields, and a
# add fields you needmarker for the object-valued ones — guessing how deep someone wants to go is worse than leaving a hole. - An
errorsblock only when the schema has one. The payload/errors convention is widespread but not universal, so it’s expanded only when that field really exists. - A nested field is reached through a root.
Company.employeeisn’t callable on its own, so it’s wrapped in a root field that returnsCompany. When several roots qualify, the caller is told, rather than the pick being passed off as obvious.
Structs§
- Example
- A drafted operation and the variables it expects.
Functions§
- build
- Draft an operation that reaches
target.