urql-devtools icon indicating copy to clipboard operation
urql-devtools copied to clipboard

Explorer overriding results

Open mdugue opened this issue 3 years ago • 3 comments

Hi,

First of all: 1. I'm not sure if this is ideed a bug but it looks pretty much like this to me. 2. I'm more than grateful for this great tooling and the work being done on it!

I just stumbled on a problem, which I think can be boiled down to this: When I send 2 queries to the same top-level schema-Query field with different selections – but same variables or none –, only one of them will be visible in the DevTools Explorer. For example, sending those 2 queries:

const FIRST_MAXCP_QUERY = gql`
query Pokemon {
  __typename
  pokemon(id: "001") {
    id
    maxCP
  }
}
`

and

const FIRST_NAME_QUERY = gql`
query Pokemon {
  __typename
  pokemon(id: "001") {
    __typename
    id
    name
  }
}

leads to either name or maxCP beeing shown in the Devtools Explorer (apparently the first response coming in)

image

Why is this happening, shouldn't the results be either merged or shown as 2 different entries? Is this related to the devtools at all or rather to internal caching? (Btw: I couldn't see any difference between standard document cache and graphcache)

reproducible via https://codesandbox.io/s/urql-devtools-overriding-results-kqr91

Thanks a lot in advance!!

mdugue avatar Dec 03 '21 20:12 mdugue

interestingly the behavior is different when quering arrays, here the results seem to get merged. Eg, sending those two queries

const POKEMONS_NAME_QUERY = gql`
  query Pokemons {
    pokemons(limit: 10) {
      id
      name
    }
  }
`;

const POKEMONS_MAXCP_QUERY = gql`
  query Pokemons {
    __typename
    pokemons(limit: 10) {
      id
      maxCP
    }
  }
`;

leads to a merged preview: image

mdugue avatar Dec 03 '21 20:12 mdugue

I experience the same behaviour. We are using very few endpoints throughout the app with lots and lots of different queries on them. I thought the explorer view as a tool to see the merged state (since we are using graphcache).

uloco avatar Aug 10 '23 09:08 uloco

Seeing this too, even when supplying a schema. Making multiple queries on an Enrolment type, each requesting a different set of fields. Each query overwrites the previous one, and I would expect the fields to accumulate.

Undistraction avatar Oct 30 '23 11:10 Undistraction