dgs-framework icon indicating copy to clipboard operation
dgs-framework copied to clipboard

bug: Cannot disable introspection point due to an error.

Open nmartin-RatedPower opened this issue 2 years ago • 4 comments

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 avatar Oct 03 '24 10:10 nmartin-RatedPower

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

ThomasD281 avatar Oct 11 '24 08:10 ThomasD281

Any update?

nmartin-RatedPower avatar Oct 17 '24 12:10 nmartin-RatedPower

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.

urs-keller avatar Oct 18 '24 06:10 urs-keller

Fixed in #2056

paulbakker avatar Nov 06 '24 21:11 paulbakker