Closed skkap closed 6 years ago
Your type definition is not a list, it should be if you want to be able to resolve an array.
@mickhansen Oh yeah, that is right. Thank you. It is just example. The actual question is, how to map this list of Sequelize Users to GraphQL ones? I am still looking for the solution.
The usual way, graphql built-in resolvers just do object[key], so that usually works if your fields are named the same as your sequelize attributes.
@mickhansen I was under the impression there should be some helper for that... Is there any example?
Helper for what part? There's a resolver helper, it's in the readme.
@mickhansen
Resolver
performs sequelize DB request by itself.
I receive sequelize entities from another service, which has complicated logic which is really difficult to define in before
callback of the resolver
.
I would like to implement resolve
method myself, but use graphql-sequelize
only for mapping of sequelize entities to graphql entities. Is it possible?
May be I don't fully understand how graphql-sequelize
works, but it should map sequelize entities to graphql entities after performing request in resolver
, right?
graphql-sequelize does not map sequelize objects to graphql types in resolvers no. sequelize instances simply just work with the default graphql field resolver. if you implement resolve() yourself you generally won't need graphql-sequelize
@mickhansen thank you for the clarification! I still can use it for attributeFields
method to define GraphQL types though.
I have custom
resolve
function in which I retrieve sequelize objects from some other function. How can I map these objects into graphql objects?