Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note for xml docs + custom naming convention #4661

Merged
merged 2 commits into from
Jan 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions website/src/docs/hotchocolate/defining-a-schema/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,38 @@ services
.AddGraphQLServer()
.ModifyOptions(opt => opt.UseXmlDocumentation = false);
```

## With a custom naming convention

If you want to use a custom naming convention and XML documentation, ensure you give the convention an instance of the `XmlDocumentationProvider` as demonstrated below; otherwise the comments won't appear in your schema.

```csharp
public class CustomNamingConventions : DefaultNamingConventions
{
// Before
public CustomNamingConventions()
: base() { }

// After
public CustomNamingConventions(IDocumentationProvider documentationProvider)
: base(documentationProvider) { }
}

// Startup
// Before
.AddConvention<INamingConventions>(sp => new CustomNamingConventions());

// After
IReadOnlySchemaOptions capturedSchemaOptions;

services
.AddGraphQLServer()
.ModifyOptions(opt => capturedSchemaOptions = opt)
.AddConvention<INamingConventions>(sp => new CustomNamingConventions(
new XmlDocumentationProvider(
new XmlDocumentationFileResolver(
capturedSchemaOptions.ResolveXmlDocumentationFileName),
sp.GetApplicationService<ObjectPool<StringBuilder>>()
?? new NoOpStringBuilderPool())));
```