You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Provide a minimal example for usage of this plugin with @apollo/server v4 and implementing graphql subscriptions.
Motivation
Couldn't find a practical example other than https://www.apollographql.com/docs/apollo-server/data/subscriptions/
to specifically deal with this plugin and fastify
Example
import{ApolloServer}from'@apollo/server';import{ApolloServerPluginLandingPageLocalDefault}from'@apollo/server/plugin/landingPage/default';importfastifyApollo,{fastifyApolloDrainPlugin}from'@as-integrations/fastify';importCorsfrom'@fastify/cors';import{env}from'@lib/env';importfastifyCookiefrom'@fastify/cookie';import{Context}from'@typings/context';importFastifyfrom'fastify';import{apolloCtxRegisterFn}from'middleware/apollo-ctx';import{errorHandler}from'middleware/error-handler';import{ctxRequestDecorator}from'middleware/global-ctx';importfastifyWebsocketfrom"@fastify/websocket";constfastify=Fastify();awaitfastify.register(fastifyWebsocket);constapollo=newApolloServer<Context>({schema: schema,// obtained from somewhereplugins: [fastifyApolloDrainPlugin(fastify),ApolloServerPluginLandingPageLocalDefault({includeCookies: true,}),],});fastify.setErrorHandler(errorHandler);awaitapollo.start();awaitfastify.register(Cors,{
...
...
...
});awaitfastify.register(fastifyCookie,{});awaitfastify.register(ctxRequestDecorator);// the ws server should technically listen to the same `/graphql` route// can't figure out what the next step is here// do I register the ws separately and bind it to GET requests on `/graphql`?// can I register it along with the apollo graphql handler?awaitfastify.register(fastifyApollo(apollo),apolloCtxRegisterFn);awaitfastify.listen({port: env.SERVER_PORT,});console.log(`🚀 Server ready at http://localhost:${env.SERVER_PORT}/graphql`);
The text was updated successfully, but these errors were encountered:
Prerequisites
🚀 Feature Proposal
Provide a minimal example for usage of this plugin with @apollo/server v4 and implementing graphql subscriptions.
Motivation
Couldn't find a practical example other than
https://www.apollographql.com/docs/apollo-server/data/subscriptions/
to specifically deal with this plugin and fastify
Example
The text was updated successfully, but these errors were encountered: