Created
April 22, 2019 12:02
-
-
Save gcoda/bd94998bdff524d037288cc60bb41cab to your computer and use it in GitHub Desktop.
Apollo Server Cloudflare worker deployment
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
const { ApolloServer, gql } = require('apollo-server-cloudflare') | |
const { | |
graphqlCloudflare, | |
} = require('apollo-server-cloudflare/dist/cloudflareApollo') | |
const typeDefs = gql` | |
type Query { | |
hello: String | |
} | |
` | |
const resolvers = { | |
Query: { | |
hello: () => 'Hello world!', | |
}, | |
} | |
const server = new ApolloServer({ | |
typeDefs, | |
introspection: true, | |
resolvers, | |
}) | |
addEventListener('fetch', event => { | |
event.respondWith( | |
graphqlCloudflare(() => { | |
return server.createGraphQLServerOptions(event.request) | |
})(event.request) | |
) | |
}) |
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
const path = require('path') | |
module.exports = { | |
target: 'webworker', | |
resolve: { | |
alias: { | |
fs: path.resolve(__dirname, './null.js'), // module.exports = {} | |
busboy: path.resolve(__dirname, './null.js'), | |
}, | |
}, | |
mode: 'production', | |
optimization: { | |
usedExports: true, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment