apollo-server/packages/apollo-server-azure-functions
Sashko Stubailo 93f052352c
Docs improvements (#692)
* Freshen up title page

* Improve homepage further

* File a PR!

* Try adding express README to sidebar

* Add READMEs to docs

* Add example page, overhaul setup

* More stuff

* Fix all old URLs

* Eliminate all mentions of graphql-server

* Fix azure functions shit
2017-12-11 23:11:11 -08:00
..
src Azure Functions bindings (#503) 2017-08-15 09:59:29 +02:00
.npmignore include readme for npm packages 2017-10-23 15:13:31 -07:00
package.json v1.2.0 2017-10-24 09:14:51 -07:00
README.md Docs improvements (#692) 2017-12-11 23:11:11 -08:00
tsconfig.json Azure Functions bindings (#503) 2017-08-15 09:59:29 +02:00

title description
Azure Functions 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'
    })(context, request);
  } else if (request.method === "GET") {
    return server.graphiqlAzureFunctions({
        endpointURL: '/api/graphql'
    })(context, request);
  }
};