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

New Apollo 2.0 server breaks suggested method for middleware with Express #73

Closed
cmcinroy opened this issue Jun 29, 2018 · 4 comments
Closed

Comments

@cmcinroy
Copy link

cmcinroy commented Jun 29, 2018

The suggested method for using Voyager as middleware with Express no longer works with the 2.0 release of Apollo.

I followed this approach:
apollographql/apollo-server#1117 (comment)

import { express as voyagerMiddleware } from 'graphql-voyager/middleware';

const PORT = 3000;

...

const { ApolloServer, gql } = require('apollo-server');
const express = require('express');

const server = new ApolloServer({ typedefs, resolvers });
const app = express();

// Mount voyager middleware
app.use('/voyager', voyagerMiddleware({ endpointUrl: '/graphql' }));
server.applyMiddleware({ app });

app.listen(PORT, () => {
  console.log(`🚀 Server ready at http://localhost:${PORT}${server.graphqlPath}`)
  console.log(`🚀 Subscriptions ready at http://localhost:${PORT}${server.subscriptionsPath}`)
});

Only opening this issue here to alert to the Apollo situation... I don't expect anything can or should change with Voyager.

@daniloferreira
Copy link

You should use apollo-server-express...
I got it working following this doc:
https://www.apollographql.com/docs/apollo-server/essentials/server.html#integrations

@IvanGoncharov
Copy link
Member

@cmcinroy Thanks for the info.
We are working towards 1.0.0 release and it would be great to include your example in README.
Can you please confirm that it still works with the latest Apollo server?

@aaronleesmith
Copy link

I can tell you it does work.

@IvanGoncharov
Copy link
Member

@aaronleesmith Thanks 👍

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

No branches or pull requests

4 participants