useQuery doesn't notify for invalid queries on local state management
See original GitHub issueIntended outcome:
The Apollo client warns me that I’m using an invalid query/field while using the useQuery
hook while dealing with local state
Actual outcome: It doesn’t display valuable information about the error. In fact, it displays nothing.
How to reproduce the issue:
There’s a Sandbox for it. You can alternate between the working and broken version by toggling commented lines on the App
component. Check the queries on queries.js
… the field name
doesn’t exist – the correct field is text
, but I get no warning about that.
Versions
@apollo/react-hooks - 3.1.3
apollo-boost - 0.4.4
graphql - 14.5.8
Additional information
In the docs, it says:
“Client-side schema
You can optionally set a client-side schema to be used with Apollo Client, through either the ApolloClient constructor typeDefs parameter, or the local state API setTypeDefs method. Your schema should be written in Schema Definition Language. This schema is not used for validation like it is on the server because the graphql-js modules for schema validation would dramatically increase your bundle size. Instead, your client-side schema is used for introspection in Apollo Client Devtools, where you can explore your schema in GraphiQL.”
Which I think it kinda invalidates this issue report? The suggestion of a friend of mine would be to include graphql-js
in development mode to notify the user and strip it out when bundling for production.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6 (1 by maintainers)
Top GitHub Comments
@yss14 I set
errorPolicy
toall
and I was able to access the error object.I’ve run into what I believe is the exact same issue – this is a seriously bad problem!
In my case – I’m wanting to use apollo local state. I modify an existing query by adding a @client field to it.
Suppose you do nothing and attempt to run a working app after making the above change. You will get a failure that provides zero information about the error.
Suppose you attempt to fix by stabbing in the dark at whatever black hole has sucked away all useful feedback about your issue. You know that you did something related to adding local state so you create typedefs, and resolvers, and add them to new ApolloClient({}) appropriately.
But there’s a bug in your resolver – and you are not returning a value for the new @client property. You get a failure with absolutely no information to help debug. You get such a failure even if the @client field is nullable btw.
Please please please, figure out how to provide useful information about this category of errors!
The lack of feedback to help debug queries with @client makes client side apollo state borderline unuseable.