Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with apollo-server ^2.2.0 #75

Closed
jgoux opened this issue Nov 14, 2018 · 11 comments
Closed

Incompatibility with apollo-server ^2.2.0 #75

jgoux opened this issue Nov 14, 2018 · 11 comments
Assignees
Labels
kind/bug A reported bug.

Comments

@jgoux
Copy link

jgoux commented Nov 14, 2018

Hello,

It seems that there is an incompatibility issue between graphql-middleware and apollo-server@^2.2.0

Here you can find an explanation about what is breaking : apollographql/apollo-server#1935 (comment)

So apparently something in graphql-middleware is turning the introspection query execution (from graphql/execution into a Promise instead of returning an object.

Another related issue : apollographql/apollo-server#1934

In the meantime, the last working version is apollo-server@2.0.5

@nicklaros
Copy link

yap, had this issue as well after update my apollo-server dependencies

@maticzav maticzav self-assigned this Nov 17, 2018
@maticzav maticzav added the kind/bug A reported bug. label Nov 17, 2018
@abernix
Copy link

abernix commented Nov 21, 2018

I'm curious if anyone experiencing this problem (and has a reproduction) would be willing to try modifying graphql-middleware's applicator.ts to have it obey graphql/introspection's isIntrospectionType predicate function prior to applying middleware to it.

Essentially, this incompatibility is occurring because the expectation Apollo Server (now) makes about introspection queries is that they should resolve synchronously (as in, they should not have asynchronous properties or resolvers). This is an expectation seems to be corroborated by graphql itself by logic similar/related to that in graphql/graphql-js#1120.

My claim is that that predicate should be applied prior to wrapping a resolver to maintain the synchronous execution dynamics of introspection queries.

@israelglar
Copy link

israelglar commented Nov 23, 2018

Hello! @abernix I'm having the same issue but can't figure out what to do to applicator.ts to fix it but I will continue to try
@maticzav since this issue is assigned to you, do have an idea when this will be resolved? Thanks!

@resao
Copy link

resao commented Dec 3, 2018

The same issue is unfortunately present when used with apollo-server-azure-functions. Although in my case I can't find an appropriate version of apollo-server-azure-functions to roll back to :(

@dortamiguel
Copy link

I have also this problem whit graphql-shield

@resao
Copy link

resao commented Dec 11, 2018

@ellipticaldoor

There is a temporary (but not very nice) solution which appears to allow "apollo-server-azure-functions": "2.2.6", "graphql-middleware": "^2.0.2" and "graphql-shield": "^4.1.0" work alongside each other.

Following this issue comment apollographql/apollo-server#1935 (comment) I was able to patch the apollo-server-core dependency in my solution and it now works

@dortamiguel
Copy link

I think I will wait for a better fix :/

@schickling
Copy link
Contributor

🎉 This issue has been resolved in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@dortamiguel
Copy link

dortamiguel commented Dec 18, 2018

@schickling Can we reopen this issue? I still get the following error using "graphql-middleware": "^3.0.0" with "apollo-server-express": "2.3.1",

(node:38309) UnhandledPromiseRejectionWarning: Error: The introspection query is resolving asynchronously; execution of an introspection query is not expected to return a `Promise`.

This is how I use it

  const typeDefs = importSchema("./src/schema.graphql");
  const schema = makeExecutableSchema({ typeDefs, resolvers });
  const schemaWithMiddleware = applyMiddleware(schema, permissions);

  const apollo = new ApolloServer({
    schema: schemaWithMiddleware,
    resolvers,
    context: (ctx) => ({ ...ctx, db })
  });

@chanlito
Copy link

@ellipticaldoor I'm using graphql-shield v5 seems to be working now.

@kallaspriit
Copy link

I can also confirm that with the latest version it works nicely again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

10 participants