Add field description inheritance from referenced types during introspection #1373
+340
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances GraphQL introspection by making fields inherit descriptions from their referenced types when no explicit description is provided. This improves API documentation by automatically propagating type descriptions to fields that reference those types.
Motivation
Currently, when a field has no description, introspection returns
null
even if the field references a well-documented type. This leads to incomplete API documentation where developers must manually duplicate type descriptions on every field that references that type.Example
With this change, the
author
field will automatically inherit the description "A user in the system" during introspection.Implementation Details
__field
introspection resolver to check if a field has no description and attempt to use the referenced type's description as a fallbacknon_null
,list_of
) by unwrapping them first before looking up the base typeTesting
Added comprehensive test coverage in
test/absinthe/introspection/field_description_inheritance_test.exs
including:All existing tests continue to pass.
Documentation
Updated the field documentation in
lib/absinthe/type/field.ex
to explain the new behavior.Breaking Changes
None. This is a backwards-compatible enhancement that only affects fields without explicit descriptions.
🤖 Generated with Claude Code