Skip to content

Instantly share code, notes, and snippets.

@thoughtspeed7
Created August 13, 2021 09:06
Show Gist options
  • Save thoughtspeed7/91850d78b2a9c0d34cb48a33a7f67bf1 to your computer and use it in GitHub Desktop.
Save thoughtspeed7/91850d78b2a9c0d34cb48a33a7f67bf1 to your computer and use it in GitHub Desktop.
Apollo GraphQL Server 3 On Google Cloud Functions
// om namah shivaya
const { ApolloServer, gql } = require('apollo-server-cloud-functions');
// dummy data
const countries = [
{
code: 'IN',
name: 'India',
},
{
code: 'US',
name: 'United States',
},
];
// typeDefs
const typeDefs = gql`
type Country {
code: String!
name: String!
}
type Query {
countries: [Country!]!
}
`;
// resolvers
const resolvers = {
Query: {
countries: () => countries,
},
};
const server = new ApolloServer({ typeDefs, resolvers });
module.exports = {
main: server.createHandler(),
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment