-
-
Notifications
You must be signed in to change notification settings - Fork 328
Generate fluent GraphQL query builders by parsing Shopify's schema #1224
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
Draft
nozzlegear
wants to merge
20
commits into
master
Choose a base branch
from
full-graphql-services
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…nto VisitedTypes This extends the GraphQL parser to properly handle query and mutation operations as distinct types from regular object types. - Add QueryOrMutation and OperationArgument types to Domain.fs - Modify VisitedTypes to include QueryOrMutation case - Implement visitOperationDefinitions function in Visitor.fs - Update VisitObjectTypeDefinitionAsync to handle QueryRoot and Mutation objects type: feature scope: graphql-parser
This was referenced Nov 5, 2025
Sanitize parameter names against list of potential dotnet keywords
…ration This commit adds infrastructure for building GraphQL queries via the services. It also restructures the parser to properly handle union types, return types and query/mutation operations. Changes: - Add core infrastructure classes (Query, QueryOptions, QueryStringBuilder, RequiredArgument) for programmatic GraphQL query construction - Create AstNodeMapper module to separate AST node mapping logic from visitor pattern - Refactor union type handling to recursively map union case nodes as VisitedTypes - Introduce ReturnType discriminated union to distinguish between field types and visited graph types in query/mutation return values - Extend IParsedContext with document access and node lookup capabilities - Add support for mapping QueryRoot and Mutation operations to QueryOrMutation types - Update Writer to generate service classes from query/mutation operations type: feature scope: graphql-parser
…se GraphQueryBuilder methods
…aint The existing GraphQueryBuilder.AddUnion methods can't be used because they constrain `TQuery` to be an inheritor of `T`. However, due to the way GraphQL unions work, and due to C#'s lack of native unions, this isn't feasible – ShopifySharp's GraphQL union cases do not inherit from their union type parent. Instead, there's an internal union type mapper for every union case that the union case is deserialized into. Long story short, the constraint didn't work with GraphQL union types because no union case inherits from its union type. type: feature scope: graphql
Extract query builder writing, utility functions, and reserved keywords into separate modules. type: refactor scope: graphql-parser
… document This commit extends the parser to generate QueryBuilder classes for all GraphQL classes, interfaces, union types, queries and mutations. This refactoring improves code modularity and lays the groundwork for more comprehensive code generation. - Move service writing logic from Writer.fs to QueryBuilderWriter.fs - Extend VisitedTypes union to include Operation case - Add tryMap function to AstNodeMapper for graceful type mapping type: feature scope: graphql-parser
The ParserContext constructor now requires a GraphQL document parameter. Also updated union type assertions to use the Cases property instead of Types. type: refactor scope: tests
Allows Connection, Edge, PageInfo, and Node types to be used with GraphQueryBuilder. These are core GraphQL/Relay specification types that need query builders generated for them. Without implementing IGraphQLObject, they don't satisfy the generic type constraint on GraphQueryBuilder<T>, causing compilation errors. type: fix scope: graphql
type: fix scope: generated-types
This fixes the issue where type names were not being reported as interfaces due to a mismatch between how interfaces were registered vs how they were looked up: - Registration: NamedType.Interface "IDisplayableError" (with "I" prefix) - Lookup: NamedType.Interface "DisplayableError" (without "I" prefix, from schema) This caused isNamedType to return false, preventing `mapFieldTypeToString` from adding the "I" prefix to field types. type: fix scope: parser, generated-types
The Visitor no longer processes QueryRoot and Mutation types itself. Instead, the QueryBuilderWriter now checks for the QueryRoot and Mutation types specifically when iterating through all definitions in the GraphDocument. Once found, it iterates over all of the field definitions on the two types and maps them to operation QueryBuilders. type: refactor scope: parser
This commit adds a new `--builders-dir` option to the CLI, and renames `--output` to `--types-dir`. The generated QueryBuilders are now written to the given `--builders-dir` directory, separating them them from the generated GraphQL classes/interfaces/union types. This commit also extracts the various filesystem functions (i.e. writeFileToPath, etc) to a new `FileSystem` module. type: feature scope: parser
ba3299b to
1568b33
Compare
This adds support for writing the `AddValue()` method to all Operation query builders for operations that return a field type instead of a visited type. type: feature scope: parser, sourcegen
type: refactor scope: dependencies
Some operations and types have the QueryRoot itself as one of their field types, so it needs to be represented as a class. type: fix scope: sourcegen, parser
The query builder argument method names were accidentally being sanitized against a list of C# and CLR keywords, which led to the argument names turning into things like "AddArgument @metaspace". They don't need to be sanitized at all, instead I meant to use the `toCasing` function. type: fix scope: sourcegen, parser
The type name string here was accidentally suffixed with "QueryBuilder", so the querybuilder for every type would think that the "foo" type was actually named "fooQueryBuilder". type: fix scope: sourcegen, parser
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.
Once merged, this PR will add a new GraphQueryBuilder base class, along with the generated query builders of all Shopify GraphQL types, union types, queries and mutations.
This will resolve #1137 and #1132.