apollographql/apollo-link-state

Strange behaviour in aliases

elessarperm opened this issue · 1 comments

I faced some strange behaviour on aliases when using apollo-link-state.
They just don't work properly. You can see that field surely exist but alias doesn't work.
image
Nothing special in the code, messages is just an array in defaults.

    "apollo-cache-inmemory": "^1.3.0-beta.6",
    "apollo-client": "^2.4.1",
    "apollo-link": "^1.2.2",
    "apollo-link-error": "^1.1.0",
    "apollo-link-http": "^1.5.4",
    "apollo-link-state": "^0.4.1",

Edit: managed to reproduce the issue with "apollo-cache-inmemory": "^1.2.9".
Just to be clear: it not only behaves like this in devtools. regular queries result in same behaviour.

I'm having the same problem with the Github API

const NODE_PACKAGE_FRAGMENT = gql`
  fragment NodePackage on Blob {
    id
    text
    name @client
  }
`

const REPOSITORY_FRAGMENT = gql`
  fragment Repository on Repository {
    id
    name
    url
    pushedAt
    isArchived
    package: object(expression: "HEAD:package.json") {
      ...NodePackage
    }
  }
  ${NODE_PACKAGE_FRAGMENT}
`

If the name @client is removed then everything works just fine.

If it's not removed then the problem begins

Missing field package in {
"__typename": "Repository",
"id": "MDEwOlJlcG9zaXRvcnk1MDAyNDg3Mw=="

Oh, if I remove the alias then everything works fine once again.