website/src/docs/nitro/analyzers.md
The ChilliCream.Nitro meta-package ships with a Roslyn source generator that simplifies Nitro integration setup. It provides compile-time warnings when required packages are missing and generates an AddDefaults() extension method that wires everything up in a single call.
If your project references HotChocolate or Fusion but is missing the corresponding Nitro integration package, you get a compile-time warning:
| Warning | Trigger |
|---|---|
| NS0001 | HotChocolate referenced without ChilliCream.Nitro.HotChocolate |
| NS0002 | HotChocolate.Fusion referenced without ChilliCream.Nitro.Fusion |
AddDefaults() extension methodWhen the correct integration package is referenced, the generator emits an AddDefaults() extension method on INitroBuilder. This method wires up the default Nitro integration with the GraphQL pipeline in a single call.
builder.Services
.AddNitro(options =>
{
options.ApiId = "my-api";
options.ApiKey = "my-key";
options.Stage = "production";
})
.AddDefaults();
You can still customize per-schema options by calling ModifyNitroOptions() on the builder afterwards:
builder.Services
.AddNitro(options =>
{
options.ApiId = "my-api";
options.ApiKey = "my-key";
})
.AddDefaults();
builder.Services
.AddGraphQLServer()
.AddQueryType<Query>()
.ModifyNitroOptions(options =>
{
options.PersistedOperations.Enabled = true;
options.Metrics.Enabled = true;
});
If AddDefaults() does not appear in IntelliSense:
ChilliCream.Nitro is referenced (this is the meta-package containing the source generator).ChilliCream.Nitro.HotChocolate for HotChocolate projects, ChilliCream.Nitro.Fusion for Fusion projects).If you cannot use the source generator, call the explicit method instead: .AddHotChocolate() or .AddFusion() on the INitroBuilder.