-
Notifications
You must be signed in to change notification settings - Fork 592
Open
Description
Describe the bug
// Next.js Custom Route Handler: https://nextjs.org/docs/app/building-your-application/routing/router-handlers
import { createSchema, createYoga } from 'graphql-yoga'
import type { NextApiRequest, NextApiResponse } from 'next'
const { handleRequest } = createYoga({
schema: createSchema<{
req: NextApiRequest
res: NextApiResponse
}>({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
`,
resolvers: {
Query: {
greetings: () => 'This is the `greetings` field of the root `Query` type'
}
}
}),
// While using Next.js file convention for routing, we need to configure Yoga to use the correct endpoint
graphqlEndpoint: '/api/graphql',
// Yoga needs to know how to create a valid Next response
fetchAPI: {
Response: Response,
Request: Request,
},
})
export { handleRequest as GET, handleRequest as POST, handleRequest as OPTIONS }
Error log
yarn build
yarn run v1.22.22
$ next build
β² Next.js 15.0.2
- Environments: .env.local, .env
Creating an optimized production build ...
β Compiled successfully
Linting and checking validity of types .Failed to compile.
.next/types/app/api/graphql/route.ts:49:7
Type error: Type '{ __tag__: "GET"; __param_position__: "second"; __param_type__: Partial<ServerAdapterInitialContext>; }'
does not satisfy the constraint 'ParamCheck<RouteContext>'.
Types of property '__param_type__' are incompatible.
Property 'params' is missing in type 'Partial<ServerAdapterInitialContext>' but required in type 'RouteContext'.
47 | Diff<
48 | ParamCheck<RouteContext>,
> 49 | {
| ^
50 | __tag__: 'GET'
51 | __param_position__: 'second'
52 | __param_type__: SecondArg<MaybeField<TEntry, 'GET'>>
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Your Example Website or App
not
Steps to Reproduce the Bug or Issue
nextjs 15
https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-nextjs
Expected behavior
No error
Screenshots or Videos
Platform
- OS: Windows
- NodeJS: 21.7.3
@graphql-yoga/*version(s):5.8.0
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
