# GraphQL Java Kickstart (Spring Boot) @link support

**URL:** <https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095>\
**Category:** Schema Design\
**Tags:** server, federation\
**Created:** [November 22, 2022, 6:10pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095 "2022-11-22T18:10:43Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Mole](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michael_mole/32/3473_2.png) [@Michael\_Mole](https://community.apollographql.com/u/Michael_Mole)\
**Post date:** [November 22, 2022, 6:10pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/1 "2022-11-22T18:10:43Z")

</div>

Hi there. I have a GraphQL service implemented using spring boot (spring-boot-starter-graphql). I’m looking to use it as a subgraph with Apollo Federation v2. The documentation here, [https://www.apollographql.com/docs/federation/building-supergraphs/supported-subgraphs/](https://www.apollographql.com/docs/federation/building-supergraphs/supported-subgraphs/), indicates that critical support for the “@link” directive is missing. However, it appears that graphql-java-support does include it - [federation-jvm/graphql-java-support/src/main/resources/definitions\_fed2\_0.graphqls at main · apollographql/federation-jvm · GitHub](https://github.com/apollographql/federation-jvm/blob/master/graphql-java-support/src/main/resources/definitions_fed2_0.graphqls#L40). Is the documentation accurate? Am I missing something?

Also, if @link is not yet available. Will this prevent me from going forward using spring-boot?

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [November 22, 2022, 6:19pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/2 "2022-11-22T18:19:25Z")

</div>

Hello 👋

`graphql-java-kickstart` is using `graphql-java-tools` to load the schema which currently does not support schema directives (see [Support schema directives · Issue #717 · graphql-java-kickstart/graphql-java-tools · GitHub](https://github.com/graphql-java-kickstart/graphql-java-tools/issues/717)). Without the presence of `@link` directive, router/gateway logic will fallback to V1 behavior.

You can definitely use Spring Boot - you can continue using Kickstart (but will be using Fed v1) or you can use some other Spring Boot implementations (e.g. [Netflix DGS Framework](https://netflix.github.io/dgs/), Official [Spring GraphQL](https://docs.spring.io/spring-graphql/docs/current/reference/html/) project or ExpediaGroup [GraphQL Kotlin](https://opensource.expediagroup.com/graphql-kotlin/docs/) (if you don’t mind Kotlin and prefer code-first solution)).

Thanks,  
Derek

---

<div class="post-metadata">

**Author:** ![Michael\_Mole](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michael_mole/32/3473_2.png) [@Michael\_Mole](https://community.apollographql.com/u/Michael_Mole)\
**Post date:** [November 22, 2022, 6:35pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/3 "2022-11-22T18:35:45Z")

</div>

Oh, I got it. I think I was confusing `graphql-java-kickstart` with `spring-boot-starter-graphql` (Official [Spring GraphQL](https://docs.spring.io/spring-graphql/docs/current/reference/html/) project). Since I’m using `spring-boot-starter-graphql`, not `graphql-java-kickstart`, I should be good for Fed v2. Thanks!

P.S. I guess I should have been looking at the compatibility for Federation JVM, not GraphQL Java Kickstart.

---

<div class="post-metadata">

**Author:** ![Sravan\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sravan_kumar/32/4462_2.png) [@Sravan\_Kumar](https://community.apollographql.com/u/Sravan_Kumar)\
**Post date:** [July 25, 2023, 6:22pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/4 "2023-07-25T18:22:30Z")

</div>

Hey Michael,

I’m trying to deal with the same approach. Do you mind sharing a git repo to point out your code with Spring boot + federation. I’m trying to use spring boot 2.7.x with spring-boot-starter-graphql, but the application is failing to start whenever i use a directive like @key

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [July 25, 2023, 9:43pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/5 "2023-07-25T21:43:22Z")

</div>

@Sravan_Kumar take a look at this [example integration](https://github.com/apollographql/federation-jvm-spring-example)

---

<div class="post-metadata">

**Author:** ![Sravan\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sravan_kumar/32/4462_2.png) [@Sravan\_Kumar](https://community.apollographql.com/u/Sravan_Kumar)\
**Post date:** [July 26, 2023, 1:54pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/6 "2023-07-26T13:54:27Z")

</div>

@dkuc thanks for the pointer, I tried to replicate the same with the below version and my application is failing to start. Any thoughts? Thank you

`Spring Boot - 2.7.14`  
`federation-graphql-java-support - 3.0.1`  
`java: 11`

Schema:

```auto
type Query {
    fetchAllMovies: [Movie!]!
}

type Movie @key(fields: "id"){
    id: ID!
    title: String
    releaseYear: Int
}

```

Error:

```auto
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'routerFunctionMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQlRouterFunction' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQlRouterFunction' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQlHttpHandler' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQlHttpHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webGraphQlHandler' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webGraphQlHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'executionGraphQlService' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Unsatisfied dependency expressed through method 'executionGraphQlService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQlSource' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.graphql.execution.GraphQlSource]: Factory method 'graphQlSource' threw exception; nested exception is SchemaProblem{errors=['Movie' [@5:1] tried to use an undeclared directive 'key']}
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.20.jar:5.3.20]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.20.jar:5.3.20]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.0.jar:2.7.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.0.jar:2.7.0]
	at com.dummybot.movies.graphql.fed.FederationMovieServiceApplication.main(FederationMovieServiceApplication.java:22) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQlRouterFunction' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQlRouterFunction' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQlHttpHandler' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQlHttpHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webGraphQlHandler' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webGraphQlHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'executionGraphQlService' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Unsatisfied dependency expressed through method 'executionGraphQlService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQlSource' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.graphql.execution.GraphQlSource]: Factory method 'graphQlSource' threw exception; nested exception is SchemaProblem{errors=['Movie' [@5:1] tried to use an undeclared directive 'key']}
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:671) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:659) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1300) ~[spring-context-5.3.20.jar:5.3.20]
	at org.springframework.web.servlet.function.support.RouterFunctionMapping.initRouterFunction(RouterFunctionMapping.java:163) ~[spring-webmvc-5.3.20.jar:5.3.20]
	at org.springframework.web.servlet.function.support.RouterFunctionMapping.afterPropertiesSet(RouterFunctionMapping.java:138) ~[spring-webmvc-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.20.jar:5.3.20]
	... 16 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'graphQlHttpHandler' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'graphQlHttpHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webGraphQlHandler' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webGraphQlHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'executionGraphQlService' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Unsatisfied dependency expressed through method 'executionGraphQlService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQlSource' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.graphql.execution.GraphQlSource]: Factory method 'graphQlSource' threw exception; nested exception is SchemaProblem{errors=['Movie' [@5:1] tried to use an undeclared directive 'key']}
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.20.jar:5.3.20]
	... 32 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webGraphQlHandler' defined in class path resource [org/springframework/boot/autoconfigure/graphql/servlet/GraphQlWebMvcAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webGraphQlHandler' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'executionGraphQlService' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Unsatisfied dependency expressed through method 'executionGraphQlService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQlSource' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.graphql.execution.GraphQlSource]: Factory method 'graphQlSource' threw exception; nested exception is SchemaProblem{errors=['Movie' [@5:1] tried to use an undeclared directive 'key']}
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.20.jar:5.3.20]
	... 46 common frames omitted
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'executionGraphQlService' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Unsatisfied dependency expressed through method 'executionGraphQlService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQlSource' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.graphql.execution.GraphQlSource]: Factory method 'graphQlSource' threw exception; nested exception is SchemaProblem{errors=['Movie' [@5:1] tried to use an undeclared directive 'key']}
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:541) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.20.jar:5.3.20]
	... 60 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQlSource' defined in class path resource [org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.graphql.execution.GraphQlSource]: Factory method 'graphQlSource' threw exception; nested exception is SchemaProblem{errors=['Movie' [@5:1] tried to use an undeclared directive 'key']}
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.20.jar:5.3.20]
	... 74 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.graphql.execution.GraphQlSource]: Factory method 'graphQlSource' threw exception; nested exception is SchemaProblem{errors=['Movie' [@5:1] tried to use an undeclared directive 'key']}
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.20.jar:5.3.20]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.20.jar:5.3.20]
	... 88 common frames omitted
Caused by: graphql.schema.idl.errors.SchemaProblem: errors=['Movie' [@5:1] tried to use an undeclared directive 'key']
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:82) ~[graphql-java-18.1.jar:na]
	at graphql.schema.idl.SchemaGenerator.makeExecutableSchema(SchemaGenerator.java:58) ~[graphql-java-18.1.jar:na]
	at org.springframework.graphql.execution.DefaultSchemaResourceGraphQlSourceBuilder.initGraphQlSchema(DefaultSchemaResourceGraphQlSourceBuilder.java:112) ~[spring-graphql-1.0.0.jar:1.0.0]
	at org.springframework.graphql.execution.AbstractGraphQlSourceBuilder.build(AbstractGraphQlSourceBuilder.java:85) ~[spring-graphql-1.0.0.jar:1.0.0]
	at org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration.graphQlSource(GraphQlAutoConfiguration.java:91) ~[spring-boot-autoconfigure-2.7.0.jar:2.7.0]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.20.jar:5.3.20]
	... 89 common frames omitted

```

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [July 26, 2023, 2:36pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/7 "2023-07-26T14:36:56Z")

</div>

Without seeing the code base it is hard to say what is missing in your setup but most likely you didn’t [transform the schema](https://github.com/apollographql/federation-jvm-spring-example/blob/main/reviews-subgraph/src/main/java/com/example/reviews/GraphQLConfiguration.java).

---

<div class="post-metadata">

**Author:** ![Sravan\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sravan_kumar/32/4462_2.png) [@Sravan\_Kumar](https://community.apollographql.com/u/Sravan_Kumar)\
**Post date:** [July 26, 2023, 3:06pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/8 "2023-07-26T15:06:43Z")

</div>

@dkuc Do you mind taking a look at the code base - [GitHub - dummybot88/federation-spring-graphql](https://github.com/dummybot88/federation-spring-graphql)

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [July 26, 2023, 3:43pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/9 "2023-07-26T15:43:37Z")

</div>

Spring GraphQL requires explicit schema transformation to enable federation → see example code linked above.

---

<div class="post-metadata">

**Author:** ![Sravan\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sravan_kumar/32/4462_2.png) [@Sravan\_Kumar](https://community.apollographql.com/u/Sravan_Kumar)\
**Post date:** [July 26, 2023, 6:58pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/10 "2023-07-26T18:58:05Z")

</div>

Thanks @dkuc it worked after making some changes to the dependency conflicts. Do we have a provision to see query plan for the subgraphs (spring boot way)?

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [July 26, 2023, 10:12pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/11 "2023-07-26T22:12:26Z")

</div>

Unsure what you mean by “spring boot way” → Apollo Studio can be used with any GraphQL server.

---

<div class="post-metadata">

**Author:** ![Sravan\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sravan_kumar/32/4462_2.png) [@Sravan\_Kumar](https://community.apollographql.com/u/Sravan_Kumar)\
**Post date:** [July 28, 2023, 9:52am UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/12 "2023-07-28T09:52:42Z")

</div>

Thank you that makes sense. Do we have any provisioning enabled to implement Apollo gateway layer using Java Spring or we need to go with JavaScript way.

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [July 28, 2023, 1:56pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/13 "2023-07-28T13:56:16Z")

</div>

We don’t have any Java support for the gateway. We support Javascript (called gateway) and Rust (called router to easily distinguish it from JS) implementations.

---

<div class="post-metadata">

**Author:** ![Sravan\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sravan_kumar/32/4462_2.png) [@Sravan\_Kumar](https://community.apollographql.com/u/Sravan_Kumar)\
**Post date:** [July 28, 2023, 2:23pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/14 "2023-07-28T14:23:06Z")

</div>

Thanks a ton for this update.

---

<div class="post-metadata">

**Author:** ![Sravan\_Kumar](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/sravan_kumar/32/4462_2.png) [@Sravan\_Kumar](https://community.apollographql.com/u/Sravan_Kumar)\
**Post date:** [August 24, 2023, 1:06pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/16 "2023-08-24T13:06:01Z")

</div>

Hi @dkuc

I hope you are doing good. I’m writing this to you as I’m struck with Apollo Client testing at React. We usually create a express server to run as bff mock for the UI to load mock data to develop UI on top of it locally. One of our UIs use Apollo client to invoke the backend ‘/graphql’ endpoint served on POST for both queries and mutation. While trying to mock the API behavior from the UI side, we are unable to serve the request based on the body passed to the graphql endpoint.

I tried making use of MSW and it is not even intercepting the graphql endpoint calls invoked by the Apollo client locally. Also, when i try to mock via rest by matching the endpoint, I see that the request is served for the /graphql endpoint with the mock data, but we couldnt capture the body of the request.

The idea here is to conditionally serve a response to the /graphql endpoint based on the request body i.e. Query or Mutation. Any suggestions on how to achieve this?

Note: Our GraphQL back end is based on Spring Boot and it only exposes the endpoint as POST.

Sample Express Code:

```auto
/* eslint-disable import/no-extraneous-dependencies */
const express = require('express')
const { graphql, rest } = require('msw')
const { createMiddleware } = require('@mswjs/http-middleware')
const { verify } = require('njwt')
const fs = require('fs')
const config = require('../config')
// import { readFileSync } from 'fs'
// import { bff, bffMock } from '../config'

const secret = 'shhhhhhhh'
const jwtRegEx = /^[bB]earer\s+([-\w-]+.[-\w]+.[-\w]+)$/
const graphApi = graphql.link('/graphql')

const query = `
  query GetTasksByAssignee($assignee: String!) {
    tasksByAssignee(assignee: $assignee) {
      name
      creationDate
      dueDate
    }
  }
`

const getJwtFromAuthHeader = req => {
  const authorizationHeader = req.header('Authorization')

  const match = jwtRegEx.exec(authorizationHeader || '')
  return match && (match[1] || '')
}

const buildMswApp = ({ mockFilename, secure }) => {
  const app = express()

  // Register json server's middleware
  app.use(
    createMiddleware(
      rest.post('/graphql', (req, res, ctx) => {
        console.log(req)
        return res(
          ctx.json({
            data: {
              tasksByAssignee: [
                {
                  id: 209757,
                  name: 'CKARTH 1 login metadata',
                  creationDate: '2011-05-23T04:22:55.000+00:00',
                  dueDate: '2011-05-25T04:22:55.000+00:00'
                }
              ]
            }
          })
        )
      }),
      graphql.operation(async (req, res, ctx) => {
        const { query } = await req.json()
        console.log(query)
        return res(
          ctx.data({
            tasksByAssignee: [
              {
                id: 209757,
                name: 'CKARTH 1 login metadata',
                creationDate: '2011-05-23T04:22:55.000+00:00',
                dueDate: '2011-05-25T04:22:55.000+00:00'
              }
            ]
          })
        )
      }),
      graphApi.query('GetTasksByAssignee', (req, res, ctx) => {
        const { assignee } = req.variables
        console.log('aa gya')
        return res(
          ctx.data({
            tasksByAssignee: [
              {
                id: 209757,
                name: 'CKARTH 1 login metadata',
                creationDate: '2011-05-23T04:22:55.000+00:00',
                dueDate: '2011-05-25T04:22:55.000+00:00'
              }
            ]
          })
        )
      }),
      graphApi.mutation('completeTask', (req, res, ctx) => {
        const { assignee } = req.variables
        console.log('aa gya')
        return res(
          ctx.data({
            tasksByAssignee: [
              {
                id: 209757,
                name: 'CKARTH 1 login metadata',
                creationDate: '2011-05-23T04:22:55.000+00:00',
                dueDate: '2011-05-25T04:22:55.000+00:00'
              }
            ]
          })
        )
      })
    )
  )

  // Configure response with correct API version
  app.use((req, res, next) => {
    const jwt = getJwtFromAuthHeader(req)

    if (secure) {
      verify(jwt, secret, err => {
        if (err) {
          res.status(401)
          res.send('Unauthorized')
        } else {
          console.log('heelo')
          res.header('Content-Type', config.bff.api.contentType)
        }
        next()
      })
    } else {
      res.header('Content-Type', config.bff.api.contentType)
      next()
    }
  })

  // Register any custom endpoints here before the jsonServer router is registered.
  // You can modify the 'mock.json' file and the changes will be reflected in the mock server.
  // app.use('/custom', customMiddleware())

  // app.post('/graphql', (req, res) => {
  // console.log(req.query.query)
  // const mockData = JSON.parse(readFileSync(mockFilename, 'utf8'))
  // res.status(200)
  // res.send(mockData.tasks)
  // })

  // Register router
  // app.use(bffMock.api.path, router)
  return app
}

module.exports = buildMswApp
 

```

In the above code, only the rest handler is intercepting the graphql endpoint, but cannot capture the body in the res variable. Whereas none of the graphql handlers intercept the graphql invocation and always result in 404.

---

<div class="post-metadata">

**Author:** ![techtreet](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/techtreet/32/5072_2.png) [@techtreet](https://community.apollographql.com/u/techtreet)\
**Post date:** [May 2, 2024, 1:41pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/17 "2024-05-02T13:41:55Z")

</div>

The sample shown below only shows how to use “@key” annotation and not others. Even the documentation doesnt even explain what each annotation is meant for so wondering how you all are able to understand how to use other annotations?

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/c/ca672921d8bbbb73220951bc678ec9cbbe225212.png)

**FEDERATION ONE**  
KEY   
REQUIRES   
PROVIDES   
FEDERATED TRACING

**FEDERATIO TWO**  
LINK   
SHAREABLE   
TAG   
OVERRIDE   
INACCESSIBLE   
COMPOSEDIRECTIVE   
INTERFACEOBJECT

---

<div class="post-metadata">

**Author:** ![dkuc](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/dkuc/32/2892_2.png) [@dkuc](https://community.apollographql.com/u/dkuc)\
**Post date:** [May 6, 2024, 5:27pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/18 "2024-05-06T17:27:26Z")

</div>

For completeness → answered [here](https://community.apollographql.com/t/how-to-implement-federation-using-spring-boot-doucmentation-talks-about-only-key-what-about-others/7467/4)

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/graphql-java-kickstart-spring-boot-link-support/5095/19 "2025-02-06T20:48:26Z")

</div>


