@barddoo/azure-functions
v0.2.2
Published
An integration for Apollo Server on Azure Functions
Downloads
133
Readme
Apollo Server Integration for Azure Functions
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
- Node.js v20 or later
- Azure Functions v4 or later
- GraphQL.js v16 or later
- Apollo Server v4 or later
Installation
npm install @as-integrations/azure-functions @apollo/server graphql @azure/functionsUsage
- Setup an Azure Function with TypeScript (or JavaScript) as per normal.
- Create a new HTTP Trigger
- Update the
index.tsto 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,
});
app.http('graphql', {
handler: startServerAndCreateHandler(server),
});- Run the Azure Functions app and navigate to the function endpoint
Contributors
- Charles Fonseca (barddoo)
- Aaron Powell (aaronpowell)
