tred-apollo-server-azure-functions
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

title: Azure Functions description: Setting up Apollo Server with Azure Functions

npm version Build Status Coverage Status Get on Slack

This is the Azure Functions integration for the Apollo community GraphQL Server. Read the docs.

Example:

const server = require('apollo-server-azure-functions');
const graphqlTools = require('graphql-tools');

const typeDefs = `
  type Random {
    id: Int!
    rand: String
  }

  type Query {
    rands: [Random]
    rand(id: Int!): Random
  }
`;

const rands = [{ id: 1, rand: 'random' }, { id: 2, rand: 'modnar' }];

const resolvers = {
  Query: {
    rands: () => rands,
    rand: (_, { id }) => rands.find(rand => rand.id === id),
  },
};

const schema = graphqlTools.makeExecutableSchema({
  typeDefs,
  resolvers,
});

module.exports = function run(context, request) {
  if (request.method === 'POST') {
    server.graphqlAzureFunctions({
      endpointURL: '/api/graphql',
      schema: schema,
    })(context, request);
  } else if (request.method === 'GET') {
    return server.graphiqlAzureFunctions({
      endpointURL: '/api/graphql',
    })(context, request);
  }
};

Read the CHANGELOG.

Package Sidebar

Install

npm i tred-apollo-server-azure-functions

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

9.34 kB

Total Files

8

Last publish

Collaborators

  • ross2411