Use netlify functions

This commit is contained in:
Trevor Blades
2022-02-24 21:07:10 -08:00
parent 262ae08628
commit 7b7bf6251a
14 changed files with 64051 additions and 87 deletions

View File

@@ -0,0 +1,35 @@
import {ApolloServer, gql} from 'apollo-server-lambda';
import {ApolloServerPluginLandingPageGraphQLPlayground} from 'apollo-server-core';
import {buildSubgraphSchema} from '@apollo/subgraph';
import {join} from 'path';
import {readFileSync} from 'fs';
import {resolvers} from './resolvers';
const typeDefs = gql(
readFileSync(join(__dirname, '../../../schema.graphql')).toString()
);
const schema = buildSubgraphSchema({
typeDefs,
resolvers
});
const server = new ApolloServer({
schema,
introspection: true,
plugins: [ApolloServerPluginLandingPageGraphQLPlayground()]
});
const apolloHandler = server.createHandler();
// workaround for netlify dev to play nice with ac3
// from https://github.com/vendia/serverless-express/issues/427#issuecomment-924580007
export const handler = (event, context, ...args) =>
apolloHandler(
{
...event,
requestContext: context
},
context,
...args
);