Skip to content

Resolve elasticgraph-apollo confusing rake warnings#1060

Open
ayousufi wants to merge 2 commits intoblock:mainfrom
ayousufi:abdullah/issue-690/fix-apollo-resolver-warnings
Open

Resolve elasticgraph-apollo confusing rake warnings#1060
ayousufi wants to merge 2 commits intoblock:mainfrom
ayousufi:abdullah/issue-690/fix-apollo-resolver-warnings

Conversation

@ayousufi
Copy link
Collaborator

@ayousufi ayousufi commented Mar 1, 2026

Problem
#690

Solution
This change updates the schema validation logic to ignore Apollo's internal resolvers via a built_in boolean param.

  • Replaces hardcoded path-based filtering in elasticgraph-schema_definition with a built_in metadata flag, ensuring the core remains agnostic of extensions like Apollo.
  • Updated the "unused resolver" warning to suggest passing built_in: true for internal resolvers intended to be available but not explicitly assigned to fields.
  • Tagged all core and Apollo-specific resolvers as built_in: true.

How Tested

  • Added a global after hook to elasticgraph-apollo schema specs to ensure no warnings (including unused resolvers) are logged during schema definition.
  • Added a unit test to ensure that warnings are not emitted by built_in resolvers when they are unused.

@ayousufi ayousufi force-pushed the abdullah/issue-690/fix-apollo-resolver-warnings branch from 8792ab8 to bbf97e0 Compare March 2, 2026 07:46
def to_dumpable_hash
{
# Keys here are ordered alphabetically; please keep them that way.
BUILT_IN => built_in,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The built_in metadata is only used when dumping schema artifacts, right? I don't think we need to bloat runtime_metadata.yaml with it since there's not a later runtime when we need it.

Two potential ideas to solve it:

  • Keep built_in as an attribute of this type, but ignore it in to_dumpable_hash/from_hash so that it isn't persisted in runtime_metadata.yaml.
  • Rather than putting built_in on this type, handle that state in another way. For example, you could add built_in_graphql_resolvers as a set to ElasticGraph::SchemaDefinition::State, add resolvers to that that get registered with built_in: true, and then check membership in that set when generating the warning.

I think I lean towards the latter as it would be kinda weird to have an attribute of a runtime metadata class that isn't persisted to runtime metadata.

# end
# end
def register_graphql_resolver(name, klass, defined_at:, **resolver_config)
# @param built_in [bool] Whether this resolver is built-in to ElasticGraph or one of its extensions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other params are defined on lines 302-305. We should keep them together. Mind moving this up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants