Skip to content
This repository has been archived by the owner on Nov 16, 2018. It is now read-only.

Always return 400 error from /gql end-point #17

Open
hassanzadeh opened this issue Mar 15, 2018 · 2 comments
Open

Always return 400 error from /gql end-point #17

hassanzadeh opened this issue Mar 15, 2018 · 2 comments

Comments

@hassanzadeh
Copy link

Dear Martin,
Thanks for this great tutorial. I'm trying to replicate this. It all works fine, except that at the point where I submit a query through apollo, the response is an error, here is the error I get from console.log:
Error: Network error: Response not successful: Received status code 400 at new ApolloError (http://mydomain.com:3000/static/js/bundle.js:3799:28) at ObservableQuery../node_modules/apollo-client/core/ObservableQuery.js.ObservableQuery.currentResult (http://mydomain.com:3000/static/js/bundle.js:2284:24) at GraphQL.dataForChild (http://mydomain.com:3000/static/js/bundle.js:18832:62) at GraphQL.render (http://mydomain.com:3000/static/js/bundle.js:18882:33) at finishClassComponent (http://mydomain.com:3000/static/js/bundle.js:27404:31) at updateClassComponent (http://mydomain.com:3000/static/js/bundle.js:27381:12) at beginWork (http://mydomain.com:3000/static/js/bundle.js:27756:16) at performUnitOfWork (http://mydomain.com:3000/static/js/bundle.js:29755:16) at workLoop (http://mydomain.com:3000/static/js/bundle.js:29819:26) at HTMLUnknownElement.callCallback (http://mydomain.com:3000/static/js/bundle.js:20073:14) at Object.invokeGuardedCallbackDev (http://mydomain.com:3000/static/js/bundle.js:20112:16) at invokeGuardedCallback (http://mydomain.com:3000/static/js/bundle.js:19969:27) at renderRoot (http://mydomain.com:3000/static/js/bundle.js:29897:7) at performWorkOnRoot (http://mydomain.com:3000/static/js/bundle.js:30545:24) at performWork (http://mydomain.com:3000/static/js/bundle.js:30498:7) at requestWork (http://mydomain.com:3000/static/js/bundle.js:30409:7) at scheduleWorkImpl (http://mydomain.com:3000/static/js/bundle.js:30263:11) at scheduleWork (http://mydomain.com:3000/static/js/bundle.js:30220:12) at Object.enqueueForceUpdate (http://mydomain.com:3000/static/js/bundle.js:25781:7) at GraphQL../node_modules/react/cjs/react.development.js.Component.forceUpdate (http://mydomain.com:3000/static/js/bundle.js:43047:16) at GraphQL.forceRenderChildren (http://mydomain.com:3000/static/js/bundle.js:18800:26) at next (http://mydomain.com:3000/static/js/bundle.js:18775:27) at Object.handleError [as error] (http://mydomain.com:3000/static/js/bundle.js:18779:32) at SubscriptionObserver.error (http://mydomain.com:3000/static/js/bundle.js:51335:20) at http://mydomain.com:3000/static/js/bundle.js:2523:82 at Array.forEach () at Object.error (http://mydomain.com:3000/static/js/bundle.js:2523:33) at http://mydomain.com:3000/static/js/bundle.js:2848:38 at http://mydomain.com:3000/static/js/bundle.js:3227:17 at Array.forEach () at http://mydomain.com:3000/static/js/bundle.js:3226:18 at Map.forEach () at QueryManager../node_modules/apollo-client/core/QueryManager.js.QueryManager.broadcastQueries (http://mydomain.com:3000/static/js/bundle.js:3221:22) at http://mydomain.com:3000/static/js/bundle.js:2790:31 at
extraInfo
:
undefined
graphQLErrors
:
[]
message
:
"Network error: Response not successful: Received status code 400"
networkError
:
Error: Response not successful: Received status code 400 at throwServerError (http://mydomain.com:3000/static/js/bundle.js:4174:17) at http://mydomain.com:3000/static/js/bundle.js:4197:13 at
stack
:
"Error: Network error: Response not successful: Received status code 400↵ at new ApolloError (http://mydomain.com:3000/static/js/bundle.js:3799:28)↵ at ObservableQuery../node_modules/apollo-client/core/ObservableQuery.js.ObservableQuery.currentResult (http://mydomain.com:3000/static/js/bundle.js:2284:24)↵ at GraphQL.dataForChild (http://mydomain.com:3000/static/js/bundle.js:18832:62)↵ at GraphQL.render (http://mydomain.com:3000/static/js/bundle.js:18882:33)↵ at finishClassComponent (http://mydomain.com:3000/static/js/bundle.js:27404:31)↵ at updateClassComponent (http://mydomain.com:3000/static/js/bundle.js:27381:12)↵ at beginWork (http://mydomain.com:3000/static/js/bundle.js:27756:16)↵ at performUnitOfWork (http://mydomain.com:3000/static/js/bundle.js:29755:16)↵ at workLoop (http://mydomain.com:3000/static/js/bundle.js:29819:26)↵ at HTMLUnknownElement.callCallback (http://mydomain.com:3000/static/js/bundle.js:20073:14)↵ at Object.invokeGuardedCallbackDev (http://mydomain.com:3000/static/js/bundle.js:20112:16)↵ at invokeGuardedCallback (http://mydomain.com:3000/static/js/bundle.js:19969:27)↵ at renderRoot (http://mydomain.com:3000/static/js/bundle.js:29897:7)↵ at performWorkOnRoot (http://mydomain.com:3000/static/js/bundle.js:30545:24)↵ at performWork (http://mydomain.com:3000/static/js/bundle.js:30498:7)↵ at requestWork (http://mydomain.com:3000/static/js/bundle.js:30409:7)↵ at scheduleWorkImpl (http://mydomain.com:3000/static/js/bundle.js:30263:11)↵ at scheduleWork (http://mydomain.com:3000/static/js/bundle.js:30220:12)↵ at Object.enqueueForceUpdate (http://mydomain.com:3000/static/js/bundle.js:25781:7)↵ at GraphQL../node_modules/react/cjs/react.development.js.Component.forceUpdate (http://mydomain.com:3000/static/js/bundle.js:43047:16)↵ at GraphQL.forceRenderChildren (http://mydomain.com:3000/static/js/bundle.js:18800:26)↵ at next (http://mydomain.com:3000/static/js/bundle.js:18775:27)↵ at Object.handleError [as error] (http://mydomain.com:3000/static/js/bundle.js:18779:32)↵ at SubscriptionObserver.error (http://mydomain.com:3000/static/js/bundle.js:51335:20)↵ at http://mydomain.com:3000/static/js/bundle.js:2523:82↵ at Array.forEach ()↵ at Object.error (http://mydomain.com:3000/static/js/bundle.js:2523:33)↵ at http://mydomain.com:3000/static/js/bundle.js:2848:38↵ at http://mydomain.com:3000/static/js/bundle.js:3227:17↵ at Array.forEach ()↵ at http://mydomain.com:3000/static/js/bundle.js:3226:18↵ at Map.forEach ()↵ at QueryManager../node_modules/apollo-client/core/QueryManager.js.QueryManager.broadcastQueries (http://mydomain.com:3000/static/js/bundle.js:3221:22)↵ at http://mydomain.com:3000/static/js/bundle.js:2790:31↵ at "
proto
:
Object

and here is part of my code:
const client = new ApolloClient({
link: new HttpLink({ uri:'http://mydomain.com:8000/gql'}),
credentials: 'same-origin',
cache: new InMemoryCache()
});

class App extends Component {
render() {
return (




  • Home

  • Login

  • Logout










)
}
}

export default App

userlistview:
const query = gql{ user(id:"VXNlclR5cGU6MQ=="){ email } }

class UsersListView extends React.Component {
render() {
let {data}=this.props
console.log(data)
if (data.loading || !data.allUsers) {
return

Loading...

}

    return (
        <div>
            {data}
        </div>
    )
}

}

Thank you so much

@hassanzadeh
Copy link
Author

Another note, the same query works in graphiql, not sure when apollo submits it does not work.

@hassanzadeh
Copy link
Author

actually, when I change the http-link to batch-http-link, it does the magic, not sure why.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant