{"action":"created","issue":{"url":"https://api.github.com/repos/prisma/graphql-yoga/issues/456","repository_url":"https://api.github.com/repos/prisma/graphql-yoga","labels_url":"https://api.github.com/repos/prisma/graphql-yoga/issues/456/labels{/name}","comments_url":"https://api.github.com/repos/prisma/graphql-yoga/issues/456/comments","events_url":"https://api.github.com/repos/prisma/graphql-yoga/issues/456/events","html_url":"https://github.com/prisma/graphql-yoga/issues/456","id":366901131,"node_id":"MDU6SXNzdWUzNjY5MDExMzE=","number":456,"title":"Order in express middleware","user":{"login":"kevinya","id":2499383,"node_id":"MDQ6VXNlcjI0OTkzODM=","avatar_url":"https://avatars0.githubusercontent.com/u/2499383?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinya","html_url":"https://github.com/kevinya","followers_url":"https://api.github.com/users/kevinya/followers","following_url":"https://api.github.com/users/kevinya/following{/other_user}","gists_url":"https://api.github.com/users/kevinya/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinya/subscriptions","organizations_url":"https://api.github.com/users/kevinya/orgs","repos_url":"https://api.github.com/users/kevinya/repos","events_url":"https://api.github.com/users/kevinya/events{/privacy}","received_events_url":"https://api.github.com/users/kevinya/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-04T17:50:18Z","updated_at":"2019-01-05T15:06:37Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nI currently use ``apollo-server-express`` with ``next.js``. I REALLY want to replace ``apollo-server`` with ``graphql-yoga`` but it does not work.\r\n\r\nIn ``graphql-yoga``, middlewares are triggered before endpoint and playground [`createHttpServer`](https://github.com/prisma/graphql-yoga/blob/master/src/index.ts#L169)\r\nnext's router is a catch all that returns 404 if there is no matching route. [`run`](https://github.com/zeit/next.js/blob/canary/packages/next-server/server/next-server.js#L152)\r\nAs next's router is triggered before yoga's endpoints, when I try to reach '/graphql' I get 404.\r\n\r\nWith `apollo-server-express`, I don't have that problem because I have a way to order express middleware [`applyMiddleware`](https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-express/src/ApolloServer.ts#L87)\r\n\r\nCould you change middleware order so that endpoint, playground are before middlewares ?\r\nThanks\r\n\r\nHere is my code with graphql-yoga :\r\n```javascript\r\nimport next from 'next';\r\nimport routes from 'next-routes';\r\n\r\nimport { GraphQLServer }  from 'graphql-yoga';\r\nimport schema from './models/schema';\r\n\r\nconst nextApp = next();\r\nconst handler = routes()\r\n  .add('home', '/', 'Home')\r\n  .getRequestHandler(nextApp);\r\n\r\nnextApp.prepare().then(() => {\r\n  const server = new GraphQLServer({ schema }).use(handler);\r\n  server.start({\r\n    endpoint: '/graphql',\r\n    playground: '/graphql',\r\n    getEndpoint: true\r\n  });\r\n});\r\n```"},"comment":{"url":"https://api.github.com/repos/prisma/graphql-yoga/issues/comments/451663193","html_url":"https://github.com/prisma/graphql-yoga/issues/456#issuecomment-451663193","issue_url":"https://api.github.com/repos/prisma/graphql-yoga/issues/456","id":451663193,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MTY2MzE5Mw==","user":{"login":"gsanikidze","id":15326244,"node_id":"MDQ6VXNlcjE1MzI2MjQ0","avatar_url":"https://avatars0.githubusercontent.com/u/15326244?v=4","gravatar_id":"","url":"https://api.github.com/users/gsanikidze","html_url":"https://github.com/gsanikidze","followers_url":"https://api.github.com/users/gsanikidze/followers","following_url":"https://api.github.com/users/gsanikidze/following{/other_user}","gists_url":"https://api.github.com/users/gsanikidze/gists{/gist_id}","starred_url":"https://api.github.com/users/gsanikidze/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsanikidze/subscriptions","organizations_url":"https://api.github.com/users/gsanikidze/orgs","repos_url":"https://api.github.com/users/gsanikidze/repos","events_url":"https://api.github.com/users/gsanikidze/events{/privacy}","received_events_url":"https://api.github.com/users/gsanikidze/received_events","type":"User","site_admin":false},"created_at":"2019-01-05T15:06:37Z","updated_at":"2019-01-05T15:06:37Z","author_association":"NONE","body":"I just removed `getEndpoint: true` and it works. Here is a server.js file\r\n\r\n`const next = require('next');\r\nconst { GraphQLServer } = require('graphql-yoga');\r\n\r\nconst dev = process.env.NODE_ENV !== 'production';\r\nconst port = process.env.PORT || 3000;\r\nconst gqlEndpoint = '/gql';\r\nconst app = next({ dev });\r\nconst handle = app.getRequestHandler();\r\n\r\napp.prepare().then(() => {\r\n    const typeDefs = `\r\n          type Query {\r\n            hello(name: String): String!\r\n          }\r\n    `;\r\n\r\n    const resolvers = {\r\n        Query: {\r\n            hello: (_, { name }) => `Hello ${name || 'World'}`,\r\n        },\r\n    };\r\n\r\n    const server = new GraphQLServer({ typeDefs, resolvers });\r\n\r\n    server.use((req, res, next) => {\r\n        if (req.path.startsWith(gqlEndpoint)) return next();\r\n       handle(req, res, next);\r\n    });\r\n\r\n    server.start( {\r\n        endpoint: gqlEndpoint,\r\n        playground: gqlEndpoint,\r\n        subscriptions: gqlEndpoint,\r\n        port,\r\n    }).catch(err => console.log('ERROR:', err))\r\n});\r\n`"}}
{"actor":{"display_login":"gsanikidze"}}