-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated to apollo-server-integration-next
- Loading branch information
Showing
7 changed files
with
1,491 additions
and
901 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,10 @@ | ||
import { RequestHandler } from 'micro'; | ||
import { startServerAndCreateNextHandler } from '@as-integrations/next'; | ||
import { createContextHandler } from 'server/lib/context'; | ||
|
||
import { createServer } from '../../server/lib/apollo'; | ||
import { cors } from '../../server/lib/micro'; | ||
import { prisma } from '../../server/prisma'; | ||
|
||
const apolloServer = createServer(); | ||
const startServer = apolloServer.start(); | ||
|
||
export const handler: RequestHandler = async (req, res) => { | ||
if (req.method === 'OPTIONS') { | ||
res.end(); | ||
return; | ||
} | ||
|
||
await startServer; | ||
await prisma.$connect(); | ||
|
||
await apolloServer.createHandler({ path: '/api/graphql' })(req, res); | ||
}; | ||
|
||
export const config = { | ||
api: { | ||
bodyParser: false, | ||
}, | ||
}; | ||
|
||
export default cors(handler); | ||
export default startServerAndCreateNextHandler(apolloServer, { | ||
context: createContextHandler, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters