Skip to content

Instantly share code, notes, and snippets.

@RusticFlare
Last active October 13, 2019 19:31
Show Gist options
  • Save RusticFlare/407ccc51387d2f987683727062fa90b8 to your computer and use it in GitHub Desktop.
Save RusticFlare/407ccc51387d2f987683727062fa90b8 to your computer and use it in GitHub Desktop.
GraphQL Cloud Function
DEPLOY.md
graphql-cloud-function-set-up.jpg
gcloud functions deploy function-1 --entry-point handler --runtime nodejs8 --trigger-http
const { ApolloServer, gql } = require('apollo-server-cloud-functions');
// Construct a schema, using GraphQL schema language
const typeDefs = gql`
type Query {
hello: String
}
`;
// Provide resolver functions for your schema fields
const resolvers = {
Query: {
hello: () => 'Hello world!',
},
};
const server = new ApolloServer({
typeDefs,
resolvers,
playground: true,
introspection: true,
});
exports.handler = server.createHandler();
{
"name": "function-1",
"version": "0.0.1",
"dependencies": {
"apollo-server-cloud-functions": "2.9.6"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment