mickhansen / graphql-sequelize

GraphQL & Relay for MySQL & Postgres via Sequelize
MIT License
1.9k stars 172 forks source link

Non nullable lists do not get treated as a list #594

Closed M-Zuber closed 6 years ago

M-Zuber commented 6 years ago

If I have the following schema:

type Book {
  name: String
  author: String
}
...
type Query {
  books(author): [Book!]!
}

and a resolver

Query: {
  books(obj, args, context, info) {
    return resolver(Book, {
      before... // some custom filtering logic
    })(obj, args.filter, context, info);
  }
}

Then when running the query, I get an error of Expected Iterable, but did not find one for field Query.books.

After debugging, the issue is coming from this check if the type is a list. as in this case, the type is GraphQLNonNull(GraphQLList)

mickhansen commented 6 years ago

https://github.com/graphql/graphql-js/blob/master/src/type/definition.js#L386

|| type.ofType instanceof GraphQLLis might fix this

M-Zuber commented 6 years ago

yeah, seems to do the trick, so made a PR