Skip to content

Update auth package to allow persisted queries - #9997

Draft
emmatown wants to merge 1 commit into
mainfrom
push-uuytqqtprsvm
Draft

Update auth package to allow persisted queries#9997
emmatown wants to merge 1 commit into
mainfrom
push-uuytqqtprsvm

Conversation

@emmatown

@emmatown emmatown commented Aug 17, 2026

Copy link
Copy Markdown
Member

This is to allow a Keystone setup where persisted queries are required for all callers except the Admin UI.

To make that approach work, the mutation that the Admin UI uses for authentication naturally needs to use a persisted query since it's not authenticated yet. This makes two small changes to @keystone-6/auth to make it possible to use it:

  • createAuth returns a persistedQueries function that returns a map of a sha256 hash to the exact query the front-end uses so it can be used in where you define
  • Uses a minimal fetch call for the sign in mutation that adds the appropriate extensions.persistedQuery while still passing the actual query in so this doesn't
    • I went with fetch directly rather than getting Apollo Client to send extensions.persistedQuery since I don't think we want to this for any other query and it seemed like unnecessary complexity

Note this doesn't use persisted queries for all Admin UI queries, I don't think this would be very practical or helpful since those queries are very dynamic so it would be a massive number of queries that essentially allows anything.

In a PR stacked on top of this, I've added an example that actually uses persisted queries in the way described above.

@emmatown
emmatown force-pushed the push-uuytqqtprsvm branch 2 times, most recently from 5397e9f to 0a0cdb2 Compare August 18, 2026 05:40
@emmatown
emmatown marked this pull request as draft August 21, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant