@as-integrations/azure-functions
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

Apollo Server Integration for Azure Functions

Build Release npm (scoped)

Introduction

An Apollo Server integration for use with Azure Functions.

This is a simple package allows you to integrate Apollo Server into an Azure Functions app.

Requirements

Installation

npm install @as-integrations/azure-functions @apollo/server graphql @azure/functions

Usage

  1. Setup an Azure Function with TypeScript (or JavaScript) as per normal.
  2. Create a new HTTP Trigger
  3. Update the index.ts to use the Apollo integration:
import { ApolloServer } from '@apollo/server';
import { startServerAndCreateHandler } from '@as-integrations/azure-functions';

// The GraphQL schema
const typeDefs = `#graphql
  type Query {
    hello: String
  }
`;

// A map of functions which return data for the schema.
const resolvers = {
  Query: {
    hello: () => 'world',
  },
};

// Set up Apollo Server
const server = new ApolloServer({
  typeDefs,
  resolvers,
});

export default startServerAndCreateHandler(server);
  1. Update the function.json HTTP output binding to use $return as the name, as the integration returns from the Function Handler:
{
  "type": "http",
  "direction": "out",
  "name": "$return"
}
  1. Run the Azure Functions app and navigate to the function endpoint

Contributors

Dependencies (4)

Dev Dependencies (14)

Package Sidebar

Install

npm i @as-integrations/azure-functions

Weekly Downloads

2,144

Version

0.1.3

License

MIT

Unpacked Size

18.5 kB

Total Files

18

Last publish

Collaborators

  • aaronpowell