Repository navigation
React Hook "useApolloServerErrors" cannot be called at the top level. #1369
Answered
by
n1ru4l
tettoffensive
asked this question in
Q&A
|
I'm attempting to migrate from Apollo Server (with Next.js), but I'm getting the following error with
import { createServer } from '@graphql-yoga/node';
import { useApolloServerErrors } from '@envelop/apollo-server-errors';
const server = createServer<{
req: NextApiRequest;
res: NextApiResponse;
}>({
schema,
cors: false,
endpoint: '/api/graphql',
plugins: [
useApolloServerErrors(),
],
});This looks like what's in the docs, so what could be going wrong? |
Answered by
n1ru4l
Apr 9, 2022
Replies: 1 comment
|
This is caused by an eslint rule https://www.npmjs.com/package/eslint-plugin-react-hooks You should only enable that for your files that actually use React and disable it for your API routes, e.g. by adding |
0 replies
Answer selected by
n1ru4l
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is caused by an eslint rule https://www.npmjs.com/package/eslint-plugin-react-hooks
You should only enable that for your files that actually use React and disable it for your API routes, e.g. by adding
/* eslint-disable react-hooks/rules-of-hooks */on top of the file.