PolyglotDataStudio.GraphQL.CLI 1.2.1

dotnet tool install --global PolyglotDataStudio.GraphQL.CLI --version 1.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local PolyglotDataStudio.GraphQL.CLI --version 1.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=PolyglotDataStudio.GraphQL.CLI&version=1.2.1
                    
nuke :add-package PolyglotDataStudio.GraphQL.CLI --version 1.2.1
                    

PolyglotDataStudio.GraphQL.CLI

A small command-line tool that generates C# code from GraphQL SDL or the JSON output of an introspection query using the T4 templates included in this project. Built for .NET 10 and using Mono.Options for command-line parsing. The CLI reads GraphQL schema files (SDL or JSON) and emits generated C# files according to the templates located in the Templates folder.

The generated C# code has a dependency on the PolyglotDataStudio.GraphQL library, which provides the base types for GraphQL objects. See the PolyglotDataStudio.GraphQL README for details on using the generated types.

Features

  • Generate C# object, interface, enum and operation models from GraphQL SDL or Introspection JSON using T4 templates.
  • Templates are included in the Templates folder and configured for design-time T4 processing.
  • Generates comprehensive C# types that map to GraphQL schema definitions, designed to work with the PolyglotDataStudio.GraphQL.

Requirements

  • .NET 10 SDK
  • The project uses Mono.Options for argument parsing
  • Output depends on PolyglotDataStudio.GraphQL library

Installation

The recommended path for usage is to install the CLI tool as a global .NET tool (optional):

dotnet tool install --global PolyglotDataStudio.GraphQL.CLI

Command-line options

This CLI provides the following options:

  • -f, --file "<file>"

    • Path to the GraphQL SDL or JSON file to be imported.
    • SDL file must conform to the GraphQL Schema Definition Language specification.
    • JSON file should be the output of a GraphQL introspection query.
  • -u or --url "<url>"

    • URL of a GraphQL endpoint to fetch the schema via introspection query.
    • Does not yet support authentication headers
    • Example: --url "https://api.spacex.land/graphql/"
  • -o, --outputDir <directory>

    • Directory where generated C# files will be written.
  • -n, --namespace "<namespace>"

    • Root namespace applied to generated types.
    • Example: --namespace "PolyglotDataStudio.GraphQL.Generated"
  • --public

    • Generate public types instead of internal; useful when packaging types into a library for shared use.
  • --partial

    • Add partial modifiers to generated classes and interfaces
  • --force

    • Do not prompt before overwriting existing files in the output directory.
  • -?, --help

    • Show usage and exit.

Examples

Generate code from a single SDL file and write output to src/Generated:

PolyglotDataStudio.GraphQL.CLI -f my-schema.graphql -o src/Generated --namespace MyCompany.GraphQL --public

Show help:

PolyglotDataStudio.GraphQL.CLI -?

Generated Types & Naming Conventions

Both C# and GraphQL are case-sensitive languages, but C# is a bit more restrictive. In particular, C# does not allow members to have the same name as their containing type. To address this, the CLI applies the following naming conventions:

  • Type names are always coerced to title case
  • Fields and other members, are coerced to camel case, except enum values

If your schema contains field names that differ only by case of their first letter, you will receive a naming collision warning. At this time, the CLI does not automatically resolve such collisions, and you will need to manually adjust your schema or update the final generated code using the partial mechanism.

While camel-case member names are not common in C#, these are idiomatic for GraphQL, and results in the lowest probability of collision. A side-effect is that member names may now collide with C# reserved keywords such as class, event and so on. In these cases the CLI prepends the C# escape character @ to the member name to avoid compilation errors.

GraphQL Introspection Query

This is the query that will be executed against a GraphQL endpoint when using the --url option. The query may be run in the GraphQL Playground or using any other tool, with the output saved into a JSON file that can also be processed by this tool.

query IntrospectionQuery {
	__schema {
	queryType { name }
	mutationType { name }
	subscriptionType { name }
	types { ...FullType }
	directives { name description locations args { ...InputValue } }
	}
}
fragment FullType on __Type {
	kind name description
	fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason }
	inputFields { ...InputValue }
	interfaces { ...TypeRef }
	enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason }
	possibleTypes { ...TypeRef }
}
fragment InputValue on __InputValue {
	name
	description
	type {
	...TypeRef
	}
	defaultValue
}
fragment TypeRef on __Type {
	kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } }

** Note that we do not yet support nested lists. The __Type fragment will support at most, a complexity of [Type!]!

GraphQL SDL (Schema Definition Language) documentation

Official resources:

Both links were verified active as of November 28, 2025.

Contributing

Contributions are welcome. Please open issues for bugs or feature requests and submit pull requests for fixes. If present, follow the repository CONTRIBUTING.md for contribution process and code-style requirements.

License

Add your project license here (for example: MIT).

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.2.1 99 4/16/2026
1.1.0 123 2/11/2026
1.0.0 108 2/4/2026

v1.2.1
✔️ Add parameter for emitting partial classes

v1.1.0
✔️ Re-organise generator to output query and response model for a given Type into a single file, rather than two separate files