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

feat: make loadPersistedQuery public #2579

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

jaulz
Copy link
Contributor

@jaulz jaulz commented Jul 3, 2024

  • Added or updated tests
  • Documented user facing changes
  • Updated CHANGELOG.md

Changes

This PR will remember persisted queries locally. The idea is related to #2561. Right now, I use the StartOperationOrOperations event to determine whether the query is allowed or not. This works fine but previously defined queries will not work anymore as soon as I release another version. Hence, I would like to check first if the query was persisted before:

$query = rescue(fn () => $graphql->loadPersistedQuery($operationId), null, false);

if ($query) {
  return true;
}

This PR makes loadPersistedQuery public and also remembers persisted queries locally to avoid hitting the cache twice.

Please let me know what you think and I can try to implement tests as well.

Breaking changes

n/a

src/GraphQL.php Outdated Show resolved Hide resolved
src/GraphQL.php Outdated Show resolved Hide resolved
@spawnia
Copy link
Collaborator

spawnia commented Jul 3, 2024

Can we just make the method public for now?

@spawnia spawnia added the enhancement A feature or improvement label Jul 3, 2024
@jaulz jaulz changed the title feat: remember persisted queries feat: make loadPersistedQuery public Jul 3, 2024
@jaulz
Copy link
Contributor Author

jaulz commented Jul 3, 2024

@spawnia sure, fine for me 😊 I anyway hope that there will be something built-in to allow pre-defined queries and mutations in the future 😉

@spawnia spawnia merged commit 76d9a4a into nuwave:master Jul 3, 2024
38 checks passed
@spawnia
Copy link
Collaborator

spawnia commented Jul 3, 2024

Thank you @jaulz, released with https://github.com/nuwave/lighthouse/releases/tag/v6.40.0.

@jaulz jaulz deleted the feat/remember-persisted-queries branch July 3, 2024 08:59
@jaulz jaulz restored the feat/remember-persisted-queries branch July 3, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants