Skip to content

Commit

Permalink
docs: correct Hive Gateway Next.js example (#6481)
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo authored Feb 6, 2025
1 parent 280f4d1 commit 6bef900
Showing 1 changed file with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ Hive Gateway can be integrated with Next.js easily as

## Example

```ts
// Next.js Custom Route Handler: https://nextjs.org/docs/app/building-your-application/routing/router-handlers
Please read the
[relevant Next.js documentation on custom router handlers](https://nextjs.org/docs/app/building-your-application/routing/router-handlers)
first.

```ts filename="app/api/route.ts"
import { createGatewayRuntime } from '@graphql-hive/gateway-runtime'
import { supergraph } from './my-supergraph'

const { handleRequest } = createGatewayRuntime({
/* Your configuration here before the following required settings */

// While using Next.js file convention for routing, we need to configure Hive Gateway to use the correct endpoint
graphqlEndpoint: '/api/graphql',

// Hive Gateway needs to know how to create a valid Next response
fetchAPI: { Response }
supergraph,
graphqlEndpoint: '/api/graphql'
})

// Export the handler to be used with the following HTTP methods
export { handleRequest as GET, handleRequest as POST, handleRequest as OPTIONS }
```

0 comments on commit 6bef900

Please sign in to comment.