Closed mcurcio closed 7 years ago
Yes, you simply use target: Model
and scope everything in your before
I'm not sure what you mean by "scope everything in your before". I tried applying a model as the target
and I am not seeing good results. My schema looks something like this:
User = sequelize.define('user', {});
const Users = sequelizeConnection({
name: 'Users',
nodeType: User,
target: User
});
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: {
users: {
type: Users.connectionType,
args: Users.connectionArgs,
resolve: Users.resolve
}
}
})
});
And when run against this query:
{
users {
pageInfo {
hasNextPage
}
}
}
I get the following error:
{
"data": {
"users": null
},
"errors": [
{
"message": "Cannot return null for non-nullable field UsersConnection.pageInfo.",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"users",
"pageInfo"
]
}
]
}
That's odd, target: Model should work, we use it a few places and then we filter based on source in the before
resolver options hook
Good to know. I'll poke around some more.
It is working now. Thanks for the guidance. I didn't make any significant changes at all ... it simply started working.
I think my issue is that I was mixing up my resolvers since I have the very similarly named objects User
and Users
where the former is a GraphQLObjectType
and the latter is a graphql-sequelize Connection. For what its worth, I did also upgrade to the latest sequelize/graphql-sequelize.
Is there currently a way to generate Relay-compatible connection schemas from a single Model (i.e. not an association)?