feat(query-spec): shared query language spec package; wire codegen + query-builder#1392
Merged
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
New zero-dependency leaf package
packages/query-spec(unscoped npm namequery-spec) defining the Constructive query language grammar — the single source of truth for filter, ordering, and pagination shapes shared by the GraphQL SDK/ORM layer and the SQL query builder.query-specexports:constarrays + derived unions:NULL/COMPARISON/DISTINCT/LIST/LIKE/PATTERN/INSENSITIVE/ARRAY/POSTGIS_FILTER_OPERATORS,FILTER_OPERATORS,LOGICAL_OPERATORS, with runtime guardsisFilterOperator()/isLogicalOperator().FieldFilter<TOperand>,RelationalFilter<TOperand>(every/some/none),Filter<TOperand>— generic over the operand type so each layer constrains what fields compare against (JSON values in the SDK; values/exprs/subqueries in SQL).OrderByItem/OrderDirection,PageInfo,ConnectionResult<T>.Wiring (no breaking changes):
graphql/codegensrc/types/query.ts: the previously inlinedFilterOperator/FieldFilter/RelationalFilter/Filter/OrderByItem/PageInfo/ConnectionResultdefinitions are deleted and re-exported fromquery-spec, so all existing@constructive-io/graphql-codegentype consumers are unaffected.postgres/query-builder:FieldFilteris now composed from the spec's operator-group unions via mapped types, preserving its per-group operand precision:query-specdep).One subtlety:
Filteris aninterface(not an intersection type) because TS's excess-property check mishandles recursive generic intersections of an index signature + named combinators (not: { field: ... }failed to compile as an intersection).Tests: new query-spec suite; query-builder 111 passing; codegen 358 passing.
Link to Devin session: https://app.devin.ai/sessions/3766c470681e402680eae001e9679801
Requested by: @pyramation