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

[regression] Apollo Cache does not work with Actions #6831

Open
giulianok opened this issue Apr 27, 2021 · 1 comment
Open

[regression] Apollo Cache does not work with Actions #6831

giulianok opened this issue Apr 27, 2021 · 1 comment
Assignees
Labels
a/api/graphql a/data c/server Related to server support/needs-triage Needs to be triaged so that we have enough information to add this to our backlog t/server/data t/server

Comments

@giulianok
Copy link

I'm currently using Hasura 2.0.0-alpha9 with Apollo Client 3.3.15

All queries, mutations, and subscriptions are working as expected, except for queries to Actions.

I have the following Action:
Screen Shot 2021-04-27 at 3 40 38 PM

The Backend responds with the correct JSON data.

Apollo Query (default) does not work, the data and error keys are empty (undefined).

This DOES not work

const { loading, data, error } = useQuery(QUERY)

This WORKS

const { loading, data, error } = useQuery(QUERY, {
    fetchPolicy: 'network-only',
  })

I'm assuming that Apollo makes the request, stores the data into the cache, reads from the cache, and then responds but it isn't being able to get the data from the cache.

I checked the Network tab and I'm getting the data

Screen Shot 2021-04-27 at 1 41 51 PM

I'm also checked it using the fetch API
Screen Shot 2021-04-27 at 1 34 47 PM

And this is from Apollo Chrome extension
Screen Shot 2021-04-27 at 2 03 35 PM
Screen Shot 2021-04-27 at 1 50 09 PM

It was working fine in Hasura 1.3.3 but stopped working on 2.0.0, is there something that changed in Actions?

@tirumaraiselvan tirumaraiselvan added this to the v2.0.0 stable milestone Apr 28, 2021
@tirumaraiselvan tirumaraiselvan added the support/needs-triage Needs to be triaged so that we have enough information to add this to our backlog label Apr 28, 2021
@tirumaraiselvan tirumaraiselvan changed the title Apollo Cache does not work with Actions [regression] Apollo Cache does not work with Actions Apr 28, 2021
@eviefp
Copy link
Contributor

eviefp commented May 17, 2021

Hello @giulianok ! I am trying to replicate this bug.

Here's what I've done:

  1. Created a new action identical to the one you provided.
  2. Created a glitch.me project which simply returns some static data in the correct shape:
app.post('/hello', async (req, res) => {
  return res.json([{
    missingCode: "code-1",
    completed: false,
    reason: "reason-1"
  },{
    missingCode: "code-2",
    completed: true
  }])
});
  1. Ran this query:
query MyQuery {
  accountStatus {
    __typename
    completed
    missingCode
    reason
  }
}

And the result I am getting is:

{
  "data": {
    "accountStatus": [
      {
        "__typename": "AccountStatus",
        "completed": false,
        "missingCode": "code-1",
        "reason": "reason-1"
      },
      {
        "__typename": "AccountStatus",
        "completed": true,
        "missingCode": "code-2"
      }
    ]
  }
}

I have tested this on 2.0.0-alpha.9.

The main point to notice here is that the __typename has the expected casing, whereas in your report, __typenames are "accountStatus" which looks wrong and may be the cause of the problem you are experiencing.

That being said, I am unable to reproduce a scenario where the __typename field has the wrong casing.

Could you try to create an easily reproducible case and share it with me? That would be very helpful in tracking down and fixing the problem you are experiencing.

@eviefp eviefp self-assigned this May 17, 2021
@0x777 0x777 removed this from the v2.0.0 stable milestone May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a/api/graphql a/data c/server Related to server support/needs-triage Needs to be triaged so that we have enough information to add this to our backlog t/server/data t/server
Projects
None yet
Development

No branches or pull requests

5 participants