Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apollo Client still fetching even though store already contains the dataIdFromObject #873

Closed
TSMMark opened this issue Nov 4, 2016 · 2 comments

Comments

@TSMMark
Copy link

TSMMark commented Nov 4, 2016

If I query an index, followed by a query of a specific record, Apollo Client does not recognize that the specific record is already present in my state.apollo.data. Instead of using the cached data, a full GraphQL request is made.

Is this expected behavior? If so, is there a different way to configure Apollo Client to recognize that the data is already fetched, and to use that data instead of requesting new data?

Here is the specific JSON from my store state.

state.apollo.data

{  
  "Artist70":{  
    "id":"70",
    "name":"Doctor Piano",
    "__typename":"Artist"
  },
  "ROOT_QUERY":{  
    "artist({\"id\":\"70\"})":{  
      "type":"id",
      "id":"Artist70",
      "generated":false
    },
    "artists":[  
      "Artist71",
      "Artist70"
    ]
  },
  "Artist71":{  
    "id":"71",
    "name":"Mr Keyboad",
    "__typename":"Artist"
  }
}

state.apollo.queries

{
  "0":{
    "queryString":"query ($id: ID!) {\n  artist(id: $id) {\n    id\n    name\n    __typename\n  }\n}\n",
    "variables":{
      "id":"70"
    },
    "previousVariables":null,
    "stopped":true,
    "loading":false,
    "networkError":null,
    "graphQLErrors":null,
    "networkStatus":7,
    "forceFetch":false,
    "returnPartialData":false,
    "lastRequestId":1
  },
  "2":{
    "queryString":"{\n  artists {\n    id\n    name\n    __typename\n  }\n}\n",
    "previousVariables":null,
    "stopped":false,
    "loading":false,
    "networkError":null,
    "graphQLErrors":null,
    "networkStatus":7,
    "forceFetch":false,
    "returnPartialData":false,
    "lastRequestId":3
  }
}

Thank you!

@helfer
Copy link
Contributor

helfer commented Nov 4, 2016

This is the expected behavior, what you're trying to do will be supported once this PR is merged and published: #809

@helfer helfer closed this as completed Nov 4, 2016
@TSMMark
Copy link
Author

TSMMark commented Nov 4, 2016

Perfect, thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
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

2 participants