score:3
applymiddleware
already adds body-parser
for the graphql endpoint -- there's no need to apply it again and doing so may be causing your issue.
additionally, i would expect applymiddleware
to be called before router.use('*', renderer)
-- otherwise, i would think the wildcard route would be used for /graphql
as well?
score:1
this error also caused by incorrect json in the body or some other problems in the body, such as unnecessary wrong invisible chars. so check generated json for errors and what is actually presents in the request body.
score:1
this error can also be raised because the body is too large.
i got it with apollo-server-micro inside a custom api route of nextjs.
it can be fixed by calling the json
function coming from micro
before apollo gets the request :
import { json } from 'micro'
import { apolloserver } from 'apollo-server-micro'
const server = new apolloserver({/*config*/})
const raisebodylimit: (handler: nextapihandler) => nextapihandler = (
handler
) => async (req, res) => {
if (req.headers['content-type'] !== 'application/json') {
return handler(req, res)
}
await json(req, { limit: '1gb' }) // this is the trick to raise body limit
return handler(req, res)
}
export default raisebodylimit(
server.createhandler({
path: '/api/graphql',
})
)
i saw this in this apollo-server's github issue.
here are some information to build an apollo server endpoint with next.js
score:2
i forgot the header content-type: application/json
score:6
in my particular case the client just missed "content-type" header with 'application/json' value. after adding that the error message has dissapeared.
Source: stackoverflow.com
Related Query
- GraphQL - POST body missing. Did you forget use body-parser middleware?
- Function components cannot have refs. Did you mean to use React.forwardRef()?
- React hook form v7 Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()
- WARNING in Unknown plugin: imageminSvgo. Did you forget to install the plugin?
- [Error: Can't find npm module 'react/package.json'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?]
- Error: JSON value of type NSstring cannot be converted of a YGValue. Did you forget the % or pt suffix
- passed to parser was not a valid GraphQL DocumentNode.you may need to use 'graphql-tag' or another method to convert your operation into a document
- Module '"domhandler"' has no exported member 'DomElement'. Did you mean to use 'import DomElement from "domhandler"' instead?
- Helmet expects a string as a child of <head>. Did you forget to wrap your children in braces
- TS18007: JSX expressions may not use the comma operator. Did you mean to write an array?
- how get id of tr and use it in post api request body in reactjs
- TypeScript > Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
- Uncaught Invariant Violation: Function components cannot have refs. Did you mean to use React.forwardRef()?
- Attempts to access this ref will fail. Did you mean to use React.forwardRef()
- Module '"*.css"' has no exported member 'CompaniesLogo'. Did you mean to use 'import CompaniesLogo from "*.css"' instead?
- Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
- when I use "=>" Why am I getting "Unexpected token. Did you mean `{'>'}` or `>`?ts" in React Component Class-
- How do you get URL parameters from react-router outside components to use in GraphQL query
- React - The value prop is required for the <Context.Provider>. Did you misspell it or forget to pass it?
- Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
- How do you use the result of a graphql query as a return value in a react functional component?
- In React I get the warning: Function component cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
- React testing error Cannot log after tests are done. Did you forget to wait for something async in your test?
- Getting undefined data when trying to use Graphql query and passing a post Id
- Missing required parameter To in the post body in react js axios using spring boot Twilio Api
- ReactJS: React-Month-Picker Error: Function components cannot have refs. Did you mean to use React.forwardRef()?
- What is {this.props.children} and when you should use it?
- Objects are not valid as a React child. If you meant to render a collection of children, use an array instead
- Warning: Unknown DOM property class. Did you mean className?
- When should you NOT use React memo?
More Query from same tag
- Not able to fetch data from graphQL in gatbsy
- Using TypeScript transpiled code utilizing es6-style classes with imports in a browser without an additional transpilation step?
- Ag-grid React: how can i save new value when i press Escape?
- use filter only if an attribute exists with map function
- Adding React-Router Link as component to Material-UI in Typescript?
- Does anyone know this error in "d3" well?
- How to add files using JSZip from remote URL in ReactJS?
- Default select tab React.js
- How to bypass policies when testing with hyperstack
- How to add properties to styled component with Typescript?
- dispatching action creator syntax react-redux
- React Grid System equivalent to Bootstrap's Grid system?
- Type '{ 'x-access-token': any; } | { 'x-access-token'?: undefined; }' is not assignable to type 'AxiosRequestHeaders | undefined'
- How to wait for an action to complete?
- Display a loading text/spinner until a component is fully loaded(text,images...etc) in React
- Make a card component as drawer Ant Design
- Flow complains about type incompatibility even though I check type first
- React Child Component Not Rendering After Change
- create-react-app eintegrity error windows
- React component with Three.js canvas is working but NOT every time
- Handle Change not working in React Select
- How to define the type of Key-Callback pairs in Typescript
- React - Parse String with Variables
- How to add event listener to the div element accessed with ref using react and typescript?
- How to link to Routes inside the component rendered by another Route with React Router
- How to allow users to click on rows
- Display filtered objects/arrays created by child component into the parent component
- Better way of extending React components
- Using onClick and React AutoBind
- after checking some condition inside render() want to update state value using setState, how can I do that?