You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upgrading an old Apollo client/server setup to use graphql-tools exclusively, BatchHttpLink queries fail with "POST body sent invalid JSON" (network error) and "POST http://localhost:4000/graphql 400 (Bad Request) batchHttpLink.ts:132" (on the console).
We tried a sandbox but it didn't like the apollo imports. :-/
To reproduce, create a basic create-react-app. We have this for our initialization:
import { BatchHttpLink } from "@apollo/client/link/batch-http"
import {
ApolloClient,
InMemoryCache,
ApolloProvider,
ApolloLink,
useQuery,
gql
} from "@apollo/client";
import Assess from './assess'
const link = ApolloLink.from([
new BatchHttpLink({uri: '[http://localhost:4000/graphql'](http://localhost:4000/graphql%27)})
])
const client = new ApolloClient({
link,
cache: new InMemoryCache()
});
function App() {
return (
<ApolloProvider client={client}>
<Assess />
</ApolloProvider>
);
}
export default App;
And we have this for a query page. (It doesn't really seem to matter what query is made or whether it exists on the server.)
On the backend, we've taken our server (which normally stitches together a bunch of schema based on environment variable settings) and hard-coded a single service. Again, it doesn't seem to matter what this points to because it never gets this far:
If we use a regular HttpLink on the client, our code works (or returns the expected errors from the service), whereas BatchHttpLink gives us the "POST body sent invalid JSON" error.
These behaviors show up when everything is running on a single Mac, PC or in a kubernetes pod hosted on AWS. Node versions are 12, 15 and 16. React version is 17.0.2 and create-react-app is 5.0.0. Using these graphql libraries:
Upgrading an old Apollo client/server setup to use graphql-tools exclusively, BatchHttpLink queries fail with "POST body sent invalid JSON" (network error) and "POST http://localhost:4000/graphql 400 (Bad Request) batchHttpLink.ts:132" (on the console).
We tried a sandbox but it didn't like the apollo imports. :-/
To reproduce, create a basic create-react-app. We have this for our initialization:
And we have this for a query page. (It doesn't really seem to matter what query is made or whether it exists on the server.)
On the backend, we've taken our server (which normally stitches together a bunch of schema based on environment variable settings) and hard-coded a single service. Again, it doesn't seem to matter what this points to because it never gets this far:
If we use a regular HttpLink on the client, our code works (or returns the expected errors from the service), whereas BatchHttpLink gives us the "POST body sent invalid JSON" error.
These behaviors show up when everything is running on a single Mac, PC or in a kubernetes pod hosted on AWS. Node versions are 12, 15 and 16. React version is 17.0.2 and create-react-app is 5.0.0. Using these graphql libraries:
The text was updated successfully, but these errors were encountered: