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
spring-example: Upgrade graphql-spring-boot-starter to 11.0.0 #103
spring-example: Upgrade graphql-spring-boot-starter to 11.0.0 #103
Conversation
@sachindshinde - this is great. I really like the simpler logic around I have a few questions about whether it could be simplified even further for Graph Builders. Some suggestions:
|
@setchy Thanks for the suggestions! I do think it would be nice for users to:
With regards to your specific suggestions:
For some clarifying context, a GraphQL type is an entity type if it has an
For the switch statements in the public interface EntityWiring {
// The GraphQL type name of the entity.
public String getName();
// Resolves a federation reference to an object representing the entity type.
public Object resolveReference(Map<String, Object> reference);
// Determines whether an object represents this specific entity type.
public boolean isType(Object object);
} We could then validate that they provide wirings for every entity type present in the schema. We could probably infer some of these automatically if the user's using a library like Regarding the automation of parsing of the federation reference, we could eliminate at least some boilerplate and provide type safety using something similar to JSON object mapping, where the user provides POJO classes and we validate them against the parsed
I'm not sure if we could do this exactly as written, as Circling back to this PR, while I believe it would be nice to provide automation and reduce boilerplate, I wouldn't say it's in scope for this PR. If you're interested in contributing to |
Thanks @sachindshinde - appreciate the thorough reply - lots of good suggestions / ideas in there. I agree, those suggestions are definitely not in the scope of this card. I'll raise a new issue shortly so we can continue the discussion and together find a nice path forward. Back to the scope of this card, I created an sample spring-boot-federation-example last weekend (which was cause for raising the original ticket #101). There are two main gotchas/quirks that are not covered in this spring-example. I'll do my best to explain them below, based on my current understanding... To illustrate, I've made a fork of your branch and made a few changes to bring it more in-line with typical graphql-java-kickstart services (use of Quirk 1 - Cannot have an empty query root node in graphql-java.This is documented in Federation.java. graphql-java-kickstart appears to enforce this at start-up the moment you implement either of the above *Resolver interfaces. If you do not define a Query type and resolver, you'll be faced with You can use Note: If you use the Quirk 2. graphql-java-kickstart by default will remove any unused types from the parsed SDL.Because unusued / unreferenced types are removed from the executable schema when doing One workaround to this is to change the the dummy query from above to return the federated type (ie: I haven't found an elegant solution to this yet, but I suspect the answer lies in either
|
…ix issues with maven surefire plugin
…k for GraphQL errors and federated tracing in the test
…boot starter now declares logback and the maven surefire plugin doesn't like it when tests log to STDOUT
…ng profile) and update tests
df5a6a5
to
22d7a76
Compare
@setchy I've looked into the Regarding the quirks you've noticed:
While it's true that you do need to specify a
If you take a look at
I think there's been a bit of a misunderstanding about
There ends up being a solution here which isn't too painful, which is namely both:
The code under Note that |
22d7a76
to
d72c028
Compare
d72c028
to
9489327
Compare
That is excellent @sachindshinde 🎉 I've reached out to the team behind
|
@setchy Thanks for reaching out to the One slight correction regarding:
You'd want to keep entity types in the executable schema, and accordingly you'd want to consider any type with the |
Our Spring Boot example was using a very old version of
graphql-spring-boot-starter
(5.10.0
), as noted in #101 . This PR upgrades the example to11.0.0
. More specifically, this PR:graphql-spring-boot-*
artifacts to11.0.0
.spring-boot-starter-*
artifacts to2.3.6.RELEASE
(the same version used bygraphql-spring-boot-*
11.0.0
).5.7.1
and switches to using the aggregator artifactjunit-jupiter
, as the Maven Surefire Plugin was encounteringNoClassDefFoundError
s without it.__resolveReference()
pattern.Instrumentation
bean wasn't getting created due to the lack of@Import(App.class)
on the test class; this has been fixed in this PR.logback.xml
, asspring-boot-starter-*
added logback to their dependency tree at some point and it's causing tests to print to stdout, which the Maven Surefire Plugin complains about since it also uses stdout to communicate between forked processes.graphql-java-tools
microservice (along with tests), set up under a non-default Spring profile.