graphql-spring-boot icon indicating copy to clipboard operation
graphql-spring-boot copied to clipboard

Query for federation-jvm

Open amarflybot18 opened this issue 4 years ago • 17 comments

Hi,

Do you have support for apollographql federation-jvm in graphql-spring-boot?

If you already have some schema files defined with custom directives, this project fails to generate schema. Especially for type Query{}.

amarflybot18 avatar Apr 16 '20 16:04 amarflybot18

Federation isn't supported yet.

oliemansm avatar Apr 16 '20 16:04 oliemansm

Could you please guide me in getting a bean for runtimeWiring out ?

amarflybot18 avatar Apr 16 '20 16:04 amarflybot18

I don't understand the question.

oliemansm avatar Apr 16 '20 16:04 oliemansm

If you look at the example mentioned in https://github.com/apollographql/federation-jvm/blob/master/spring-example/src/main/java/com/apollographql/federation/springexample/InventorySchemaProvider.java. For that example to work with Custom Scalars, we would need additional Runtime argument.

public static SchemaTransformer transform(final Reader sdl, final RuntimeWiring runtimeWiring) {
        return transform(new SchemaParser().parse(sdl), runtimeWiring);
    }

amarflybot18 avatar Apr 16 '20 16:04 amarflybot18

This would have backward compatibility with all the datafetchers precreated.

amarflybot18 avatar Apr 16 '20 16:04 amarflybot18

My first comment was that we don't support federation yet, and we also don't expose RuntimeWiring in any way at the moment. We do intend to add support for Federation at some point and any contributions to add support for Federation are appreciated, but until then there's nothing much we can do for you.

oliemansm avatar Apr 16 '20 16:04 oliemansm

Thanks.

amarflybot18 avatar Apr 16 '20 16:04 amarflybot18

@amarflybot18 @oliemansm - I'd be interested to help work on this item.

I do have several services using federation-jvm in production and had to do some pretty hacky workarounds to get it working in the interim.

setchy avatar Dec 20 '20 12:12 setchy

@setchy Thanks for reaching out and the offer to help out! If it helps I can invite you to our Slack to discuss details and/or align with rest of the team where necessary?

oliemansm avatar Dec 20 '20 12:12 oliemansm

That would be perfect @oliemansm

setchy avatar Dec 20 '20 13:12 setchy

some updates happening on the federation-jvm spring-boot kickstart example

  • https://github.com/apollographql/federation-jvm/pull/103
  • https://github.com/apollographql/federation-jvm/issues/101

setchy avatar Apr 15 '21 21:04 setchy

Apollo updated their graphql-java-tools example within https://github.com/apollographql/federation-jvm/tree/master/spring-example a few weeks ago.

I also have an example of a federation + 2 graphql-spring-boot services over at https://github.com/setchy/spring-boot-federation-example

Hopefully these are good resources to help you our @amarflybot18

While on the topic, I have raised a separate enhancement in Apollo federation-jvm to simplify the amount of boilerplate code needed - https://github.com/apollographql/federation-jvm/issues/108

setchy avatar May 06 '21 21:05 setchy

Hello,

we use kickstart + spring boot on our backend with micro services. And we needed to add support for Federation. So with examples provide by @setchy I have created lib, which we currently use until kickstart support federation directly. I have put code to repo as possible reference. README.md and tests show how it works so maybe it may be used for future kickstart implemetation or help other guys struggling with tfederation and kickstart combo.

Principle is pretty same as use kickstart lib itself - implement interface for Federation type FederationReferenceResolver<Account>.

@Component
class AccountResolver : GraphQLResolver<Account>, FederationReferenceResolver<Account> {
    fun balance(context: Account): String = "5.7"
}

data class Account(
    val iban: String,
    val currency: UUID
)

stengvac avatar Nov 12 '21 15:11 stengvac

Apollo updated their graphql-java-tools example within https://github.com/apollographql/federation-jvm/tree/master/spring-example a few weeks ago.

I also have an example of a federation + 2 graphql-spring-boot services over at https://github.com/setchy/spring-boot-federation-example

Hopefully these are good resources to help you our @amarflybot18

While on the topic, I have raised a separate enhancement in Apollo federation-jvm to simplify the amount of boilerplate code needed - apollographql/federation-jvm#108

Do you have any idea to use Dataloader in ReferenceResolver?

paptimuslun avatar May 30 '22 12:05 paptimuslun

Any plans to merge this feature @oliemansm ? Thank you!

PhilippS93 avatar Aug 23 '22 13:08 PhilippS93

There aren't any plans to work on this atm. If somebody has the time to create a PR for this I'm happy to merge it though.

oliemansm avatar Aug 24 '22 10:08 oliemansm

There aren't any plans to work on this atm. If somebody has the time to create a PR for this I'm happy to merge it though.

Are there requirements on how it should work? Introducing new interface/reusing some. As I have made example https://github.com/graphql-java-kickstart/graphql-spring-boot/issues/395#issuecomment-967192027 is it ok to work like this?

stengvac avatar Aug 30 '22 08:08 stengvac