Integration with Azure Functions — GraphQL Yoga documentation.
Azure Functions is a serverless environment that supports JavaScript, and GraphQL Yoga runs on it
with a few lines of code.
Installation
npm i @azure/functions graphql-yoga graphql
yarn add @azure/functions graphql-yoga graphql
pnpm add @azure/functions graphql-yoga graphql
bun add @azure/functions graphql-yoga graphql
Example
graphql.ts
import { createSchema, createYoga } from 'graphql-yoga'import { app, InvocationContext } from '@azure/functions'// The `InvocationContext` is your server contextconst yoga = createYoga<InvocationContext>({ // This is the path to your Azure function graphqlEndpoint: '/api/yoga', schema: createSchema({ typeDefs: /* GraphQL */ ` type Query { greetings: String } `, resolvers: { Query: { greetings: () => 'This is the `greetings` field of the root `Query` type' } } })})app.http('yoga', { methods: ['GET', 'POST'], authLevel: 'anonymous', handler: yoga})
You can also check a full example on our GitHub repository
here.
This site uses cookies for analytics and improving your experience.