apollo icon indicating copy to clipboard operation
apollo copied to clipboard

useLazyQuery requires the document again when calling `load`

Open TheDutchCoder opened this issue 2 years ago • 0 comments

Describe the bug A clear and concise description of what the bug is. When destructuring load from useLazyzQuery, you need to provide the query again for some reason, eventhough it should already be provided.

Example:

const { load } = useLazyQuery<GetCollection, GetCollectionVariables>(GET_COLLECTION)

const doThing = async () => {
  load({ id: '1' }) // Error, because the first argument is the document, even though it's already passed into `useLazyQuery`
}

// This works
const doOtherThing = async () => {
  load(GET_COLLECTION, { id: '1' })
}

To Reproduce Steps to reproduce the behavior:

  1. Destructure load from useLazyQuery with a provided document
  2. Call load in some secondary function with just the variables
  3. You should see an error in your IDE, because document is the first argument

Expected behavior load to already know the document (as it's passed into useLazyQyery) and just be able to call it with variables, just like you do with mutations.

Versions vue: 3.2.36 vue-apollo: 4.0.0-alpha.16 @apollo/client: 3.5.10

TheDutchCoder avatar Jul 22 '22 14:07 TheDutchCoder