Extracting the SDL without running the app #4862
-
Hi. I need the SDL to generate client-side code. I'm aware of the When using a REST/Swagger API, i can extract the OpenAPI spec with: Is there something similar to extract the SDL for GraphQL? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You will not get around running your executable in some way. What you could do, is add a CLI argument to your application and if it's set just write the schema to a file and exit the application. var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddGraphQLServer();
// ...
var app = builder.Build();
if (args.Any(a => a == "--export"))
{
var executor = await app.Services
.GetRequiredService<IRequestExecutorResolver>()
.GetRequestExecutorAsync();
string schema = executor.Schema.Print();
// write it to a file, etc.
return;
}
app.MapGraphQL();
// ... Then you just need to run your application with the argument: dotnet run -- --export |
Beta Was this translation helpful? Give feedback.
You will not get around running your executable in some way. What you could do, is add a CLI argument to your application and if it's set just write the schema to a file and exit the application.
Then you just need to run your application with the argument: