这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@nozzlegear
Copy link
Owner

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.

…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
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
…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
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
@nozzlegear nozzlegear force-pushed the full-graphql-services branch from ba3299b to 1568b33 Compare November 12, 2025 06:08
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GraphQL service classes with pre-generated methods matching Shopify's queries and mutations

2 participants