Skip to content

[Proof of concept] Custom key #189

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

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])
})

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

Successfully merging this pull request may close these issues.

1 participant