Resolver itself doesn't validate/enforce relationships between the fields
graphql-codegen
Consequently, fields can return any return value as long as defined by the resolver function
You can continue to query for the nested sub-fields by referencing any of the parent fields' field values as a querying argument
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 }
!
)!
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 nullResolver 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 };