Skip to content

Commit

Permalink
Merge pull request #202 from justin-tay/description_gh-pages
Browse files Browse the repository at this point in the history
Customizing GraphQL field definition
  • Loading branch information
aklish authored Jul 13, 2024
2 parents 39b53dd + ad5a669 commit 9959197
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pages/guide/v7/11-graphql.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,25 @@ Type coercion between the API and underlying data model has common support acros
--------------------------

Configuring custom error responses is documented [here]({{site.baseurl}}/pages/guide/v{{ page.version }}/09-clientapis.html#custom-error-responses).

## Customizing Field Definition Description
--------------------------

The `GraphQLFieldDefinition` can be customized by setting a `GraphQLFieldDefinitionCustomizer` to the `GraphQLSettingsBuilder`.

```java
@Configuration
public class ElideConfiguration {
@Bean
GraphQLSettingsBuilderCustomizer graphqlSettingsBuilderCustomizer() {
return graphqlSettings -> graphqlSettings.graphqlFieldDefinitionCustomizer(
((fieldDefinition, parentClass, attributeClass, attribute, fetcher, entityDictionary) -> {
Description description = entityDictionary.getAttributeOrRelationAnnotation(parentClass,
Description.class, attribute);
if (description != null) {
fieldDefinition.description(description.value());
}
}));
}
}
```

0 comments on commit 9959197

Please sign in to comment.