You don't have to write resolvers for each field. By default, if you didn't specify a resolver for a field, GraphQL will return an object property with the same name.
Imagine that you have "Spaceships" table with 30 fields. This will be our "main" resolver for querying all spaceships:
And now, because we didn't write resolvers for Spaceship fields, GraphQL will return spaceship.model if we queried model field, spaceship.weight for weight field and same applies for every other queryable field. Hope that this makes sense 🙂
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You don't have to write resolvers for each field. By default, if you didn't specify a resolver for a field, GraphQL will return an object property with the same name.
Imagine that you have "Spaceships" table with 30 fields. This will be our "main" resolver for querying all spaceships:
And now, because we didn't write resolvers for
Spaceship
fields, GraphQL will returnspaceship.model
if we queriedmodel
field,spaceship.weight
forweight
field and same applies for every other queryable field. Hope that this makes sense 🙂