Persistent queries issue with GraphQLi error
See original GitHub issueThe new code added in the persistent queries commit https://github.com/sysgears/apollo-fullstack-starter-kit/commit/de2fdec1e0182bb949ac89020c8d2f0298c72946 breaks GraphQLi.
TypeError: req.body.map is not a function
The following code in src/server/api_server
assumes that all req.body are arrays.
app.use(
'/graphql',
(req, resp, next) => {
req.body = req.body.map(body => {
return {
query: invertedMap[ body.id ],
...body
};
});
next();
},
);
I have not investigated what is involved with persistent queries so I cannot say this fix is correct, but this does protect the map from getting called on a non-array:
import { invert, isArray } from 'lodash';
...
app.use(
'/graphql',
(req, resp, next) => {
if (isArray(req.body)) {
req.body = req.body.map(body => {
return {
query: invertedMap[ body.id ],
...body
};
});
}
next();
},
);
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Automatic persisted queries - Apollo GraphQL Docs
A persisted query is a query string that's cached on the server side, along with its unique identifier (always its SHA-256 hash). Clients...
Read more >Automatic persisted query in Apollo Client and Server is not ...
The problem is the formatError function. @apollo/client needs to know when it has to resend the query and it uses the GraphQL error...
Read more >Top GraphQL Errors and How to fix them
When there is a network error while trying to contact a GraphQL server, due to either the server being down or timeouts etc,...
Read more >Using Persisted Queries · - OneGraph
Persisted queries are an advanced GraphQL feature that allow clients to pre-register queries with the server. In a typical workflow, ...
Read more >GraphQL error handling to the max with Typescript, codegen ...
In the first version of the query resolver, we were returning objects that matched the GraphQL types and were tagged with the __typename...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vlasenko I think this ok. As long as you can still use GraphQL in dev mode this is fine with me.
Nope not working. Fresh started. Go to graphiql by the button up right corner. Try to get post with Id.