Repository navigation
feat(graphql): document option and query params in the url - #154
Merged
Merged
Conversation
Adapters can declare additional createRequest fields with a new generic, so they are type checked only on clients using that adapter. The devtools endpoint getter also receives the request options to read those fields. Refs #153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the document option the endpoint becomes a URL path appended to client.url. Query params go through the adapter mapper and are appended to the URL, on GET query and variables win on collision. Keys contain the operation name from the document and the path. Without the document option the endpoint still holds the document and the URL is client.url. Closes #153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs #153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getEndpointAndMethod now takes the request and the client. The extra parameter for the request options broke the max-params lint rule in CI. Refs #153 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎉 This PR is included in version 9.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #153
Summary
A GraphQL request can now have its own URL path, and
setQueryParams()reaches the URL.queryandvariablesstay in the body.queryandvariables, which win on collision (also for forms likequery[]=x).unstable_queryParamsMapper, which may return a string or an object.document:endpointis still the document and the URL is stillclient.url.Changes by package
Adaptergeneric lets an adapter declare extracreateRequestfields, sodocumentis a type error on other adapters and survives mapper setters. The devtools endpoint getter also receives the request options.createGraphqlMockingServerhandlesdocumentrequests and matches the full path. It would otherwise have thrown on them.Decisions to review
document. Keys also contain the path (POST_GetUser/User--), because otherwise/v1/Userand/v2/Userwould share cached data. Keys of requests withoutdocumentare unchanged.document. The issue says "nothing changes" there, but also lists ignored query params as a limitation. Those requests now go toclient.url?source=app, which only affects code already callingsetQueryParams().document.ExtractGqlRouteParamsis not connected tocreateRequesttoday, and agqldocument can't be read at the type level.send({ payload })still needs thepayloadgeneric, which the example in the issue leaves out. String documents can usepayload: ExtractGqlRouteParams<typeof USER_QUERY>.QueryParamsType | string | undefined, sosetQueryParams({...})compiles without declaringqueryParams.Known limitations
setQueryParamsMapperConfigreplaces the defaults, including encoding, so a partial config sends unencoded values. The docs show spreadingstringifyDefaultOptions.Test plan
Same steps as CI, run from the repository root with exit codes checked:
pnpm buildpnpm lint(run per package, 12 of 12 with exit code 0)pnpm typecheckpnpm test(firebaseandfirebase-adminare excluded by the script)graphql: 118 tests, 10 runs in a row before the lasthyper-flowfix, including E2E against a real HTTP server that checks the path and query stringexpectTypeOfand@ts-expect-error🤖 Generated with Claude Code