fix(bindx): empty paginate body in count query (dual graphql-builder copy)#46
Merged
Merged
Conversation
…nate body
The standalone count query (added in v0.1.42 for the top-level DataGrid total
count) was the only query whose selection set was constructed inside the
`@contember/bindx` package — `ContemberAdapter.buildCountQuery` built
`pageInfo { totalCount }` GraphQlField nodes from bindx's own
`@contember/graphql-builder` import.
The query printer (`GraphQlQueryPrinter.processSelectionSet`) decides whether
to emit a field via `node instanceof GraphQlField`. When a consumer's
node_modules resolves a different `@contember/graphql-builder` copy for
`@contember/bindx` than for `@contember/client-content`, that instanceof check
fails, the fields are silently dropped, and the query serializes to an empty
`paginate<Entity> { }` — invalid GraphQL ("Syntax Error: Expected Name,
found }"). List/get/mutation queries were unaffected because their selection
sets are all built inside `@contember/bindx-client`, matching the printer's copy.
Fix: move count selection construction into `@contember/bindx-client`
(`buildCountSelection`), so every GraphQlField flowing into the printer comes
from the same graphql-builder copy. `@contember/bindx` no longer imports
`@contember/graphql-builder` at all (dependency dropped), preventing this class
of dual-copy bug from recurring.
Adds a serialization regression test asserting the count query renders a
non-empty `pageInfo { totalCount }` body.
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.
Problém
Standalone count query (přidaná v 0.1.42 pro total count u top-level
<DataGrid>) se u některých konzumentů serializovala s prázdným tělem:→ server vrací
Syntax Error: Expected Name, found "}". List/get/mutace fungovaly.Root cause
GraphQlQueryPrinter.processSelectionSetrozhoduje o vyrenderování pole přesnode instanceof GraphQlField.ContemberAdapter.buildCountQuerybyl jediné místo, které konstruovalo selection set (pageInfo { totalCount }) přímo v balíčku@contember/bindxpřes jeho vlastní import@contember/graphql-builder. Když si konzument (zde stage npicloud) vnode_modulesrozliší pro@contember/bindxjinou kopii@contember/graphql-buildernež pro@contember/client-content(kde žije printer),instanceofselže, pole se tiše zahodí a tělo je prázdné.List/get/mutace nebyly zasaženy, protože jejich selection sety se staví uvnitř
@contember/bindx-client— tedy v kopii, kterou printer pozná.Oprava
@contember/bindx-clientjakobuildCountSelection()→ všechnyGraphQlFieldjdoucí do printeru pocházejí ze stejné kopie graphql-builderu.@contember/bindxuž@contember/graphql-buildervůbec neimportuje (závislost odebrána) → tahle třída chyb se nemůže vrátit.pageInfo { totalCount }.Test plan
bun run typecheck— čistýbun run build— čistýtests/bindx-client/countQuerySerialization.test.ts+ existujícítests/unit/adapter/countQuery.test.ts+tests/bindx-client/qb.test.ts— vše procházímain(browser testy vyžadující server + 1 form test), žádné nové