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

data and error fields in useQuery hook empty. #324

Closed
daphnesmit opened this issue Nov 21, 2023 · 0 comments
Closed

data and error fields in useQuery hook empty. #324

daphnesmit opened this issue Nov 21, 2023 · 0 comments

Comments

@daphnesmit
Copy link

This is probably an Apollo bug but wanted to double check.

I use apollo link rest like so:

query ContentPart($htmlUrl: String!) {
  contentPart(htmlUrl: $htmlUrl) @rest(type: "ContentPartHtml", path: ":htmlUrl") {
    id 
    html 
  }
}

const restLink = new RestLink({
    uri: BASE_URL_OF_API,
    customFetch: fetch,
    responseTransformer: async (response, typeName) => {
      const html = await response.text()
      return {
        id: response.url,
        html,
        __typename: typeName
      }
    }
});

return new ApolloClient({
    link: authLink.concat(restLink),
    cache,
})

Then I try to make use of Apollo clients useQuery:


  const {data, error} = useQuery(ContentPartDocument, {
    variables: {
      htmlUrl: url,
    },
    client,
   onCompleted:(data)=> console.log(data)
  })

Where the returned data and error from the useQuery hook are undefined, but the data in onCompleted is set and the call is made successfully...

Is this a bug in Apollo client?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant