Skip to content

GraphQLQueryWatcher does not propagate failure to watching code if watch is not supposed to fetch #3507

Open
@dfed

Description

@dfed

Summary

I just spent most of today debugging an issue that I think would have been much easier to debug if the GraphQLQueryWatcher had a small change to it.

These lines mean that any query watch whose cache policy is .returnCacheDataDontFetch will fail silently if a query is made that results in the watch encountering a ApolloAPI.JSONDecodingError.missingValue error (or other error, but that's the one I got stuck on today).

Ideally, the GraphQLQueryWatcher would propagate an error to the self.resultHandler callback rather than eating the error. This could be as simple as adding an else after the linked lines above.

Version

1.16.1

Steps to reproduce the behavior

I've attempted to simplify the problem I hit earlier today to a very minimal repro. I have not tested these steps, however.

Have a schema:

type Query {
  me: User!
}

type User implements Node {
  id: ID!
  name: String!
  isActive: Bool!
}

Have a query that is executed on app launch, and then watched (with a cache policy .returnCacheDataDontFetch) after the first query successfully pulls data from the network:

query AppLaunchQuery {
  me {
    id
    name
    isActive
  }
}

Have a malformed query that is executed later:

query MalformedQuery {
  me {
    # No ID in this query means that the watch doesn't know what user we're dealing with
    name
    # No isActive in this query which means the user that we pull down is not a complete `User`, and therefore is missing a value
  }
}

After the MalformedQuery is executed, the watch on the AppLaunchQuery will permanently fail, and the adopting app will never be notified via a callback.

Logs

Anything else?

This is tangentially related to #3501

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions