question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Where clause not working with graphql: "15.0.0"

See original GitHub issue

I was just setting up a new project and noticed that using “graphql”: “^15.0.0” didn’t work well with the latest join-monster package.

Main issue that I noticed is that where clause wasn’t honored.

Here are the packages that I was using:

  "dependencies": {
    "express": "^4.17.1",
    "express-graphql": "^0.9.0",
    "graphql": "^15.0.0",
    "join-monster": "^2.1.0",
    "knex": "^0.21.1",
    "pg": "^8.0.3"
  }

Relevant parts of the code:

const Account = new graphql.GraphQLObjectType({
    name: 'Account',
    fields: () => ({
      id: { type: graphql.GraphQLString },
      name: { type: graphql.GraphQLString },
      email: { type: graphql.GraphQLString },
    }),
  });
  
  Account._typeConfig = {
    sqlTable: 'account',
    uniqueKey: 'id',
  }

const QueryRoot = new graphql.GraphQLObjectType({
    name: 'Query',
    fields: () => ({
      hello: {
        type: graphql.GraphQLString,
        resolve: () => "Health check successful!"
      },
      account: {
        type: Account,
        args: { 
            id: { type: graphql.GraphQLNonNull(graphql.GraphQLString) } 
        },
        where: (accountTable, args, context) => {
            return `${accountTable}.id = '${args.id}'`
        },
        resolve: (parent, args, context, resolveInfo) => {
          return joinMonster.default(resolveInfo, {}, sql => {
            console.log(sql);
            return knex.raw(sql);
          });
        }
      },
    })
  });
  
  const connectedSchema = new graphql.GraphQLSchema({
    query: QueryRoot,
  });

When using graphql 15, the sql statement that was produced inside the resolver didn’t have the where clause. As soon as I downgraded to 14.1.1 all worked fine.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lorensrcommented, Nov 14, 2020

Glad to hear! And just released as v3.0.0

1reaction
alexbbtcommented, Jul 17, 2020

This is already being worked on here: https://github.com/join-monster/join-monster/pull/418

Read more comments on GitHub >

github_iconTop Results From Across the Web

apollo-server-express 2.11 + graphql 15.0 = error: Must ...
Upon upgrading the graphql package to 15.0.0, the package apollo-server-express throws an error as soon as it's being included.
Read more >
id cannot be used in graphQL where clause? - Stack Overflow
However, when I tried to update the row with 'id' where clause, the console shows error. "message": "Unknown column 'NaN' in 'where clause'", ......
Read more >
type-graphql/Lobby - Gitter
This gets me the error CannotDetermineGraphQLTypeError: Cannot determine GraphQL input type for 'where' of 'FindOneOptionsInput' class. Does the value used as ...
Read more >
Deprecations by version - GitLab Docs
We haven't observed imports using this tool. There has been no activity on the open related issues on GitLab. The gitlab-runner exec command...
Read more >
(0 , import_defineToJSON.default) is not a function - Bugs
If the import statement is removed, the error goes away. ... the defineToJSON file (https://github.com/graphql/graphql-js/issues/2646).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found