Skip to content

Conversation

ramiel
Copy link

@ramiel ramiel commented Feb 17, 2022

⚠️ This is not a real PR, just a working proof of concept to address some existing issues.
⚠️ The changeset is big because I need to use this PR from github directly. Only visitor.js has relevant changes

  • What kind of change does this PR introduce?
    Feature

  • What is the current behavior? (You can also link to an open issue here)
    The key cannot be changed dynamically

  • What is the new behavior (if this is a feature change)?
    A feature for which is possible to customise the key even if it's autogenerated. This address several issues as Conditional Fetching #157 and Feature Request: Ability to override auto-generated key #158

  • Other information:
    The idea is to enable:

Conditional fetching

const result = sdk.useMyQuery(variables, undefined, {
  // This option let you customise the generated key. The key is passed as parameter to the function
  customKey: (key) => isTrue ? key : null
})

override the generated key

const result = sdk.useMyQuery(variables, undefined, {
  // This option let you customise the generated key. The key is passed as parameter to the function
  customKey: (key) => ([...key, customValue])
})

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

Successfully merging this pull request may close these issues.

1 participant