Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1.87 KB

File metadata and controls

34 lines (25 loc) · 1.87 KB

GraphOS Webhook Listener

Example code that listens to a GraphOS webhook notification

The code in this repository is experimental and has been provided for reference purposes only. Community feedback is welcome but this project may not be supported in the same way that repositories in the official Apollo GraphQL GitHub organization are. If you need help you can file an issue on this repository, contact Apollo to talk to an expert, or create a ticket directly in Apollo Studio.

What's Inside

The code that lives in api/webhook.ts is example Typescript code for a Vercel Function that can be called by GraphOS Studio when a new supergraph is built. This is an example in Vercel, but you could apply this code or logic to any runtime, serverless or not, you just need a public endpoint for GraphOS to call.

Inside the function we validate that it is a proper build notification and there are no composition errors, then fetch the schema from the provided url. Once we have the schema we could do a number of things such as:

  • Save the file to an external store on our cloud as a duplicate copy of GraphOS
  • Pass the schema to a GraphOS Router via the --supergraph flag
  • Send another notification to some other system like Slack or email that a new supergraph has launched

Run Locally

  • Clone the repo
  • Install the latest LTS version of Node (see nvm)
  • Install dependencies
    npm install
  • Start the app using the Vercel CLI locally:
    npm run vercel

Endpoints

  • /api/hello Simple test endpoint that returns a hello world message
  • /api/webhook Example Webhook that understands GraphOS Build Notifications