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

bug: Cannot disable introspection point due to an error. #2024

Closed
nmartin-RatedPower opened this issue Oct 3, 2024 · 4 comments
Closed

bug: Cannot disable introspection point due to an error. #2024

nmartin-RatedPower opened this issue Oct 3, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@nmartin-RatedPower
Copy link

Please read our contributor guide before
creating an issue.

Expected behavior

It is expected that setting the dgs.graphql.introspection.enabled=false property will disable introspection.

Actual behavior

The property dgs.graphql.introspection.enabled=false is set but the application returns the following message.

11:51:40.143 [main] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'disableIntrospectionContextContributor' defined in class path resource [com/netflix/graphql/dgs/autoconfig/DgsAutoConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.netflix.graphql.dgs.autoconfig.DgsAutoConfiguration; factoryMethodName=disableIntrospectionContextContributor; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [com/netflix/graphql/dgs/autoconfig/DgsAutoConfiguration.class]] for bean 'disableIntrospectionContextContributor' since there is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.netflix.graphql.dgs.springgraphql.autoconfig.DgsSpringGraphQLAutoConfiguration; factoryMethodName=disableIntrospectionContextContributor; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.class]] bound. 
11:51:40.150 [main] INFO  o.s.b.a.l.ConditionEvaluationReportLogger - 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 
11:51:40.166 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'disableIntrospectionContextContributor', defined in class path resource [com/netflix/graphql/dgs/autoconfig/DgsAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

It works correctly if done through the spring property.

Steps to reproduce

I just added the property in my .properties file. Anyways I think could be useful specify the versions wich in working with:

DGS version 9.1.1
Springboot version 3.3.0

If you have any doubt don't hesite to ask question about it.

Note: A test case would be highly appreciated, but we understand that's not always possible

@nmartin-RatedPower nmartin-RatedPower added the bug Something isn't working label Oct 3, 2024
@ThomasD281
Copy link

ThomasD281 commented Oct 11, 2024

I see same problem and can only enable introspection by setting these properties both to true

dgs.graphql.introspection.enabled: true
spring.graphql.schema.introspectionenabled: true

If both are false the same exception as stated above occurs. Setting one of these properties to true and the other to false does not make introspection working for me.

dgs-version: 9.1.2
spring-boot: 3.3.0

@nmartin-RatedPower
Copy link
Author

Any update?

@ls-urs-keller
Copy link

ls-urs-keller commented Oct 18, 2024

I also have this problem, I looked into the configurations:

Setting dgs.graphql.introspection.enabled=false also automagically sets spring.graphql.schema.introspection.enabled=false resulting in this error:

The bean 'disableIntrospectionContextContributor', defined in class path resource [com/netflix/graphql/dgs/autoconfig/DgsAutoConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [com/netflix/graphql/dgs/springgraphql/autoconfig/DgsSpringGraphQLAutoConfiguration.class] and overriding is disabled.

When running with debug=true:

   DgsAutoConfiguration#disableIntrospectionContextContributor matched:
      - @ConditionalOnProperty (dgs.graphql.introspection.enabled=false) matched (OnPropertyCondition)

   DgsSpringGraphQLAutoConfiguration#disableIntrospectionContextContributor matched:
      - @ConditionalOnProperty (spring.graphql.schema.introspection.enabled=false) matched (OnPropertyCondition)

I only set dgs.graphql.introspection.enabled=false the spring.graphql.schema.introspection.enabled=false seems to be automatically set when the former is set.

I guess since DgsSpringGraphQLAutoConfiguration runs before DgsAutoConfiguration
the disableIntrospectionContextContributor bean defined in DgsAutoConfiguration should have the annotation @ConditionalOnMissingBean

Setting spring.graphql.schema.introspection.enabled=false instead of dgs.graphql.introspection.enabled=false is a workable solution for us.

iparadiso added a commit that referenced this issue Nov 6, 2024
paulbakker added a commit that referenced this issue Nov 6, 2024
Improve handling of introspection properties.
@paulbakker
Copy link
Collaborator

Fixed in #2056

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants