https://github.com/soenneker/soenneker.graphql.generator
A command line tool for generating API clients from GraphQL schemas
https://github.com/soenneker/soenneker.graphql.generator
csharp dotnet generation generator graphql graphqlgenerator util
Last synced: about 1 month ago
JSON representation
A command line tool for generating API clients from GraphQL schemas
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.graphql.generator
- Owner: soenneker
- License: mit
- Created: 2026-03-10T17:07:18.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-06-08T00:55:56.000Z (about 1 month ago)
- Last Synced: 2026-06-08T02:23:15.989Z (about 1 month ago)
- Topics: csharp, dotnet, generation, generator, graphql, graphqlgenerator, util
- Language: C#
- Homepage: https://soenneker.com
- Size: 204 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/soenneker.graphql.generator/)
[](https://github.com/soenneker/soenneker.graphql.generator/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/soenneker.graphql.generator/)
#  Soenneker.GraphQL.Generator
### A command line tool for generating API clients from GraphQL schemas
## Installation
```
dotnet add package Soenneker.GraphQL.Generator
```
## Usage
**Library:** Inject `IGraphQLGenerator` and either:
- call `Generate(schemaContent, config)` to get a `GenerationResult` with generated C# files and type counts
- call `Generate(schemaContent, config, cancellationToken)` to generate from an in-memory SDL string and write all files to `config.OutputDirectory`
**CLI (gql2cs):** Build and run the `Soenneker.GraphQL.Generator.Cli` project, or run the published `gql2cs` executable:
```bash
gql2cs --config ./gql2cs.json
```
### Library example
```csharp
var config = new GeneratorConfig
{
Namespace = "MyCompany.MyApi.GraphQL",
EntryClientName = "MyApiClient",
OutputDirectory = "./Generated"
};
await graphQlGenerator.Generate(schemaSdl, config, cancellationToken);
```
The generated entry client is written to the output root as `.cs` rather than under the `Clients` folder.