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
Spaceshipfields, GraphQL will returnspaceship.modelif we queriedmodelfield,spaceship.weightforweightfield and same applies for every other queryable field. Hope that this makes sense 🙂