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

[apollo-server-fastify] playground not working #4463

Closed
marcopeg opened this issue Aug 8, 2020 · 21 comments
Closed

[apollo-server-fastify] playground not working #4463

marcopeg opened this issue Aug 8, 2020 · 21 comments

Comments

@marcopeg
Copy link

marcopeg commented Aug 8, 2020

I followed the instructions at https://www.npmjs.com/package/apollo-server-fastify and the /graphql endpoint works but it doesn't run the playground even with playground: true, introspection: true in the settings.

Versions

"dependencies": {
  "fastify": "3.2.0",
  "apollo-server-fastify": "2.16.1"
},

Expected behavior:

Going to /graphql with a browser should run the playground

Actual behavior:

It shows: GET query missing.

How to reproduce it:

You can run the example in a CodeSandbox:
https://codesandbox.io/s/wispy-dream-66j5g?file=/package.json:197-281

@ghost
Copy link

ghost commented Aug 10, 2020

Same here, when using it with nestJs.
Got the same result of GET query missing.

... 
"@nestjs/platform-fastify": "^7.4.2",
"apollo-server-fastify": "^2.16.1",
...
 export const graphQLConfig: GqlModuleOptions = {
    typePaths: ['./**/*.graphql'],
    // playground: environment.isDevelopment,
    playground: true,
    ...
}

@a7ul
Copy link

a7ul commented Aug 10, 2020

Faced the same issue.
Seems like its because this package doesnt support fastify v3.
Downgrading to fastify 2 makes it work.

I guess we can either wait for #4356 to land or downgrade to fastify v2 for the time being.

@ghost
Copy link

ghost commented Aug 11, 2020

Faced the same issue.
Seems like its because this package doesnt support fastify v3.
Downgrading to fastify 2 makes it work.

I guess we can either wait for #4356 to land or downgrade to fastify v2 for the time being.

Exactly... In my case I will wait and use GraphiQL for now. Will keep an eye on #4356

@mpeirone
Copy link

mpeirone commented Oct 9, 2020

I have the same issue, do you know any workaround?

@Duduzera1997
Copy link

+1

@NickMandylas
Copy link

Would love an update for Fastify v3!

@phattranky
Copy link

phattranky commented Oct 18, 2020

To fix this issue, I simply upgrade the apollo-server-fastify to "apollo-server-fastify": "^3.0.0-alpha.3" .

The alpha version seems not safe, But I didn't see any errors so far

@Duduzera1997
Copy link

To fix this issue, I simply upgrade the apollo-server-fastify to "apollo-server-fastify": "^3.0.0-alpha.3" .

The alpha version seems not safe, But I didn't see any errors so far

@phattranky This works for me, for now my application does not need something 100% safe, thanks!

@inakineitor
Copy link

@phattranky @Duduzera1997 I upgraded to the alpha version but get this error. What version of the graphql and @nestjs/graphql packages are you using?

(node:1501) UnhandledPromiseRejectionWarning: TypeError: this.apolloServer.installSubscriptionHandlers is not a function
    at GraphQLModule.<anonymous> (/Users/inakineitor/Documents/Couponara/couponara-backend/node_modules/@nestjs/graphql/dist/graphql.module.js:97:35)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/inakineitor/Documents/Couponara/couponara-backend/node_modules/tslib/tslib.js:111:62)
(node:1501) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1501) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@Duduzera1997
Copy link

@phattranky @Duduzera1997 I upgraded to the alpha version but get this error. What version of the graphql and @nestjs/graphql packages are you using?

(node:1501) UnhandledPromiseRejectionWarning: TypeError: this.apolloServer.installSubscriptionHandlers is not a function
    at GraphQLModule.<anonymous> (/Users/inakineitor/Documents/Couponara/couponara-backend/node_modules/@nestjs/graphql/dist/graphql.module.js:97:35)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/inakineitor/Documents/Couponara/couponara-backend/node_modules/tslib/tslib.js:111:62)
(node:1501) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1501) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"@nestjs/graphql": "^7.7.0",
"@nestjs/platform-fastify": "^7.4.4",
"apollo-server-fastify": "^3.0.0-alpha.3",",
"graphql": "^15.3.0",
"graphql-tools": "^6.2.4"

@inakineitor
Copy link

Weird. I have the same versions for everything but graphql-tools, for which I have ^6.2.5. I decided to change back to express for now until apollo-server-fastify 3 leaves alpha. Thanks @Duduzera1997!

@abernix
Copy link
Member

abernix commented Nov 3, 2020

For those attempting to use Apollo Server 3.x for its newer Fastify version, please see #4356 (comment), which is a comment I wrote for a similar audience on another PR which introduced the functionality. In particular, pay attention to my suggestion in that comment about reading the v3 CHANGELOG.md for details on how installSubscriptionsHandlers is affected (Subscriptions has been de-coupled from the core of the project, but is still installable separately).

@simoami
Copy link

simoami commented Nov 13, 2020

Thanks @abernix for the update. We are working with a client to deploy a graphql gateway/orchestrator solution. We have an sla for high throughput, which is why I'm recommending Fastify as the underlying web framework. Apollo server needs to side with performance because it often ends up in the forefront ingesting all traffic in transitional architectures, and therefore Fastify (the performance web framework) is equally important to prioritize. I am excited to get graphql and Apollo into production in the near future and thanks for the great work.

@tonimedina-pri
Copy link

+1

@glasser
Copy link
Member

glasser commented May 4, 2021

This is fixed on the release-3.0 branch, which supports Fastify v3 (only). Apollo Server 3.0 is now under active development; I hope to get some alphas out within a week.

@glasser glasser closed this as completed May 4, 2021
@genu
Copy link

genu commented May 26, 2021

Although this issue may be fixed, I'm unable to test it with 3.0.0-alpha.4 due to startup error:

TypeError: this.ensureStarting is not a function at ApolloServer.createHandler (/node_modules/apollo-server-fastify/dist/ApolloServer.js:22:14)

@glasser
Copy link
Member

glasser commented May 26, 2021

@genu What version of apollo-server-core is installed? There might be an issue there.

That said I'll have another alpha out pretty soon hopefully; there's been a lot of improvements since the last one.

@marcopeg
Copy link
Author

@genu I finally got it working by also installing apollo-server-core@3.0.0-alpha.4 (same version as apollo-server-fastify). Here is my working package.json: https://github.com/forrestjs/forrestjs/blob/master/packages/service-fastify-gql/package.json

@glasser Somehow, I and some others didn't figure this out by reading the docs. Your last comment pointed me in the right direction.

Do you think it might be useful to make it more explicit in the docs?

@genu
Copy link

genu commented May 29, 2021

I'll test that configuration on my end and report back.

Thx

@tkow
Copy link

tkow commented Jun 5, 2021

I found current preview version has possibility affects your yarn.lock or package.lock version polluted.
If you use yarn, it can fix resolutions until next release.

See the detail: #5278

@glasser
Copy link
Member

glasser commented Jun 7, 2021

@marcopeg Yes, planning to get peer deps right as part of AS3 release. #5210.

NexZhu added a commit to daotl/nestjs-prisma-starter that referenced this issue Aug 26, 2021
Currently using `apollo-server-fastify@3.0.0-alpha.4` and patched `@nestjs/graphql@8.0.2`
(`@nestjs/graphql` not supporting Apollo v3 yet) to workaround the following issue:
apollographql/apollo-server#4463 (comment).
For the patch see: https://www.apollographql.com/docs/apollo-server/migration/#subscriptions
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests