HomeToolsAbout a20k

Fields

Fields

Resolver itself doesn't validate/enforce relationships between the fields

  • Even the integrity of the the fields' return values are enforced by the types generated from graphql-codegen

Consequently, fields can return any return value as long as defined by the resolver function

Nested Fields

You can continue to query for the nested sub-fields by referencing any of the parent fields' field values as a querying argument

Field Orders

Primitive types should be defined above the custom fields

type User { id: ID! # cannot be null pets: [Pets] name: String! # cannot be null age: Int }

Non-null Fields (!)

! indicates that the field cannot be null

# type definitions type User { id: ID! # cannot be null name: String! # cannot be null age: Int }

Above example is requiring id and name fields to have a non-null value

  • age field can be null

Handle Fetch Error on Field Manually

Resolver should explicitly handle null data on fetch

const queriedData = fetch('/some-data'); if(!queriedData || !queriedData.targetAttribute) { throw Error('targetAttribute does not exist'); } const resolverFields = { id: queriedData.id, targetAttribute: queriedData.targetAttribute };
© VincentVanKoh