You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make graphql-java have a multi module project structure #336
I had a go at this and the dependencies are execution are a bit skew if at the moment
I split into
graphql-java-api
graphql-java-execution
For example graphql.execution.ExecutionStrategy is used by graphql.GraphQL both as an interface and it will slip in implementation classes such as SimpleExecutionStrategy.
We can split out "execution" say without re-arranging these code deps.
This got me thinking - what are we trying to achieve with multi module?
Is it jdk6 / jdk8 split - that is code that runs on the base jdk6 base and some new code that is jdk8?
If thats the case we can simplify by having one main "api" dep and a separate "jdk8" only sub module
This got me thinking - what are we trying to achieve with multi module?
Is it jdk6 / jdk8 split - that is code that runs on the base jdk6 base and some new code that is jdk8?
Yes, for me it's the JDK6/8 split.
Also, I know some people are using just the language features (i.e. @hepin1989 at Taobao) and have written their own execution code.
If I had time to do this split right now, I would separate out the (i) language and then (ii) parts of the execution framework that would be common to all execution strategies (coercing enum, coercing scalars, things like that).
The initial motivator for breaking up is now obsolete: We switched to Java 8.
@dminkovsky Do you think it should still be done?
The most obvious candidate is probably the relay package imho: this should really live in its own module. ( @aschrijver )
Hello Andi and Arnold,
If someone can do it I think it should be done. I understood
`graphql-relay-js` to be more useful as an example implementation guide
(who is actually using arrays as connection data?), and I experienced the
same with our Relay package. I really appreciate the simplicity of Andi's
decision to include it because it adds no dependencies and one whole class,
but it took me a while to get my head around Relay and in part it was
because I was confused by the meaning of "Relay support" and what that
actually entailed. People talk about the "ergonomics" of Relay being subpar
and I definitely experienced that by way of these helper packages that just
confused me. But that may be just me.
Anyway, if anyone can allocate time now to split things up, Relay would be
a good candidate for its own module. Or to be removed altogether.
PS Relay is changing now. I don't know the details of the new Relay but I
bet there are some differences in expectations from the backend.
пн, 10 апр. 2017 г. в 12:24, Andreas Marek <notifications@github.com>:
Hello Andi and Arnold,
If someone can do it I think it should be done. I understood
`graphql-relay-js` to be more useful as an example implementation guide
(who is actually using arrays as connection data?), and I experienced the
same with our Relay package. I really appreciate the simplicity of Andi's
decision to include it because it adds no dependencies and one whole class,
but it took me a while to get my head around Relay and in part it was
because I was confused by the meaning of "Relay support" and what that
actually entailed. People talk about the "ergonomics" of Relay being subpar
and I definitely experienced that by way of these helper packages that just
confused me. But that may be just me.
Anyway, if anyone can allocate time now to split things up, Relay would be
a good candidate for its own module. Or to be removed altogether.
PS Relay is changing now. I don't know the details of the new Relay but I
bet there are some differences in expectations from the backend.
пн, 10 апр. 2017 г. в 12:24, Andreas Marek ***@***.***>:
The initial motivator for breaking up is now obsolete: We switched to Java
8.
@dminkovsky <https://github.com/dminkovsky> Do you think it should still
be done?
The most obvious candidate is probably the relay package imho: this should
really live in its own module. ( @aschrijver
<https://github.com/aschrijver> )
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#336 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AANWZaFz430bjYHxflds4RNcNlIDwOhVks5rulezgaJpZM4MNnVe>
.
Closing this for now as its mostly been addressed.
I appreciate that there are some other reasons for an extra module such as breaking out relay support but in general I dont think its worth it right now and good issue hygeine says close issues you are not doing
@bbakerman Would this issue be relevant still? In graphql-kotlin we have discussed being able to have more of the execution implemented in a kotlin way so that we can take full advantage of things like coroutines and Flow. However graphql-java has lots of features that we wouldn't want to reimplement like the parser and ast.
Would this be something that would be considered so that graphql-java could be the core GraphQL JVM library to use? Then we could reuse some of the modules in client side libraries as well.
@smyrick can you explain it a bit more why multiple modules/project would help you? which client side are you referring to? Which dependency makes it problematic for you to just use the parts you are interested in and ignore the rest? (GraphQL Java has intentionally no "real" dependency)
We still have the idea of splitting graphql java up one day, but it is not a concrete plan at the moment. It would be great to understand better how it would benefit you.
In our library, we would like to have a pure Kotlin execution strategy of the schema. This way we can take full advantage of coroutines. Once we build a schema, we are basically limited right now of not going any deeper than calling graphql-java GraphQL.executeAsync(). Building a schema object does not need to be in a Kotlin implementation, but executing reuses a lot of the same code is not sharable today. We wouldn't want to do an entire rewrite of the library in Kotlin just for the added benefit in execution, so if graphql-java was more modular we could reuse your schema/query parser, schema objects, and printers but implement our own execution.
Then beyond our library for the server side, I am sure that other libraries, client and server side, (See apollo-android-compiler) would love to also share things like a common lexer and parser.
@andimarek Looking at the existing folder structure and packages there are a couple areas where you could publish standalone libraries and these could be re-used and built upon by others using the JVM in the GraphQL community
execution
This module is already pretty well self contained and is only consumed up by the root level. It does consume other parts like schema and language but those can also be other modules.
schema
This is going to be a fairly large module and consumed by many but the point of separation here is that defining all the schema objects and their structure and rules for the GraphQL spec is separate from the execution module or the analysis module. The schema printer could even be its own module or just bundled here
analysis
Already on it's own, just consuming others so easily separated
relay
Already on it's own, just consuming others so easily separated
parser, language, util, introspection and others
I view these as part of the core library as they are used by all other modules. As a first attempt to split the library this would probably just be called graphql-java-core and contain everything that doesn't fit in the above categories
Then end result could be that the modules are published as a separate library but then you still can have a module called graphql-java that just depends on all the others to provide a single dependency for those that want a simplified version. Separating into different modules would make separation a little easier for maintainers and allow for sub-version updates if you wanted too.
Would the maintainers still be interested in pursuing this idea?
I have previously had a go at splitting the graphql-java execution when we did the nextgen execution strategy and again when we did the Nadel entry point.
I will agree that as is its difficult to invent new execution strategies that are significantly different to the ones provided.
They key coupling points are the GraphQL class to ExecutionStrategy and also a three way coupling between GraphQL, ExecutionStrategy and Instrumentation.
The GraphQL class by design is a major coupling point. Its the input, the doc parsing, the execution, the validation rules and so on all as one entry point. I think
this coupling is good however I think we need to take those common aspects of it and put them into new subclasses so they can be more easily re-used
This was the code that I copied twice during nextgen/nadel new entry points. I think this proves how it needs to be made into more re-useable components.
The other major coupling is that Instrumentation is ExecutionStrategy dependent and completely coupled to that implmentation. By its very nature the Instrumentation
has callback methods that suit the ExecutionStrategy and hence they cannot easily be re-used between new ExecutionStrategy implemenations. Again
we can confirm this via the nextgen/nadel exercises.
I think we should make a breaking change and make ExecutionStrategy and Instrumentation interfaces with very light shapes. This way the GraphQL
class can hold them and later code can "up cast" them to known shapes as they need to.
The challenge with Instrumentation is parsing (eg onParse) and validation (onValidation) and then and common entry point of onExecution. Perhaps there can be the
same instrumentExecutionInput / instrumentExecutionResult style methods left in place.
I dont think we need to make graphql-java a multi module code base to achieve this. I will grant that multi modulee allows you to better confirm
depedencies directions but its not essential. Its a lot easier to work on a single moduke code base for sure.
Activity
bbakerman commentedon Feb 28, 2017
I had a go at this and the dependencies are execution are a bit skew if at the moment
I split into
graphql-java-api
graphql-java-execution
For example graphql.execution.ExecutionStrategy is used by graphql.GraphQL both as an interface and it will slip in implementation classes such as SimpleExecutionStrategy.
We can split out "execution" say without re-arranging these code deps.
This got me thinking - what are we trying to achieve with multi module?
Is it jdk6 / jdk8 split - that is code that runs on the base jdk6 base and some new code that is jdk8?
If thats the case we can simplify by having one main "api" dep and a separate "jdk8" only sub module
dminkovsky commentedon Feb 28, 2017
Yes, for me it's the JDK6/8 split.
Also, I know some people are using just the language features (i.e. @hepin1989 at Taobao) and have written their own execution code.
If I had time to do this split right now, I would separate out the (i) language and then (ii) parts of the execution framework that would be common to all execution strategies (coercing enum, coercing scalars, things like that).
dminkovsky commentedon Feb 28, 2017
Because if you look at all the execution strategies, they all copy paste that coercing code and complete value code one way or another.
He-Pin commentedon Feb 28, 2017
I think we could split it to these modules:
With this kind of structure,I think this will greatly help the commnity.
aschrijver commentedon Mar 2, 2017
I think the Relay code should also merit a separate module (or even a separate project) There are more client implementations such as Apollo Client.
andimarek commentedon Mar 10, 2017
We are discussing the general Java 8 topic here: #338
andimarek commentedon Apr 10, 2017
The initial motivator for breaking up is now obsolete: We switched to Java 8.
@dminkovsky Do you think it should still be done?
The most obvious candidate is probably the relay package imho: this should really live in its own module. ( @aschrijver )
dminkovsky commentedon Apr 10, 2017
dminkovsky commentedon Apr 17, 2017
And then you have PRs like #360 that actually improve the Relay support. So perhaps I'm just not a visionary :).
dminkovsky commentedon Apr 18, 2017
graphql-java#336 - initial work to get multi gradle project support i…
graphql-java#336 - more work to get multi gradle project support in p…
bbakerman commentedon May 24, 2017
Closing this for now as its mostly been addressed.
I appreciate that there are some other reasons for an extra module such as breaking out relay support but in general I dont think its worth it right now and good issue hygeine says close issues you are not doing
smyrick commentedon Jan 3, 2020
@bbakerman Would this issue be relevant still? In graphql-kotlin we have discussed being able to have more of the execution implemented in a kotlin way so that we can take full advantage of things like coroutines and Flow. However graphql-java has lots of features that we wouldn't want to reimplement like the parser and ast.
Would this be something that would be considered so that graphql-java could be the core GraphQL JVM library to use? Then we could reuse some of the modules in client side libraries as well.
andimarek commentedon Jan 3, 2020
@smyrick can you explain it a bit more why multiple modules/project would help you? which client side are you referring to? Which dependency makes it problematic for you to just use the parts you are interested in and ignore the rest? (GraphQL Java has intentionally no "real" dependency)
We still have the idea of splitting graphql java up one day, but it is not a concrete plan at the moment. It would be great to understand better how it would benefit you.
Thanks
smyrick commentedon Jan 6, 2020
+cc @dariuszkuc
In our library, we would like to have a pure Kotlin execution strategy of the schema. This way we can take full advantage of coroutines. Once we build a schema, we are basically limited right now of not going any deeper than calling graphql-java
GraphQL.executeAsync(). Building a schema object does not need to be in a Kotlin implementation, but executing reuses a lot of the same code is not sharable today. We wouldn't want to do an entire rewrite of the library in Kotlin just for the added benefit in execution, so if graphql-java was more modular we could reuse your schema/query parser, schema objects, and printers but implement our own execution.Then beyond our library for the server side, I am sure that other libraries, client and server side, (See apollo-android-compiler) would love to also share things like a common lexer and parser.
smyrick commentedon Jan 31, 2020
@andimarek Looking at the existing folder structure and packages there are a couple areas where you could publish standalone libraries and these could be re-used and built upon by others using the JVM in the GraphQL community
executionschemaandlanguagebut those can also be other modules.schemaexecutionmodule or theanalysismodule. The schema printer could even be its own module or just bundled hereanalysisrelayparser,language,util,introspectionand othersgraphql-java-coreand contain everything that doesn't fit in the above categoriesThen end result could be that the modules are published as a separate library but then you still can have a module called
graphql-javathat just depends on all the others to provide a single dependency for those that want a simplified version. Separating into different modules would make separation a little easier for maintainers and allow for sub-version updates if you wanted too.Would the maintainers still be interested in pursuing this idea?
bbakerman commentedon Feb 3, 2020
I have previously had a go at splitting the graphql-java execution when we did the nextgen execution strategy and again when we did the Nadel entry point.
I will agree that as is its difficult to invent new execution strategies that are significantly different to the ones provided.
They key coupling points are the
GraphQLclass toExecutionStrategyand also a three way coupling betweenGraphQL,ExecutionStrategyandInstrumentation.The
GraphQLclass by design is a major coupling point. Its the input, the doc parsing, the execution, the validation rules and so on all as one entry point. I thinkthis coupling is good however I think we need to take those common aspects of it and put them into new subclasses so they can be more easily re-used
This was the code that I copied twice during nextgen/nadel new entry points. I think this proves how it needs to be made into more re-useable components.
The other major coupling is that
InstrumentationisExecutionStrategydependent and completely coupled to that implmentation. By its very nature the Instrumentationhas callback methods that suit the
ExecutionStrategyand hence they cannot easily be re-used between newExecutionStrategyimplemenations. Againwe can confirm this via the nextgen/nadel exercises.
I think we should make a breaking change and make
ExecutionStrategyandInstrumentationinterfaces with very light shapes. This way theGraphQLclass can hold them and later code can "up cast" them to known shapes as they need to.
The challenge with
Instrumentationis parsing (eg onParse) and validation (onValidation) and then and common entry point ofonExecution. Perhaps there can be thesame
instrumentExecutionInput/instrumentExecutionResultstyle methods left in place.I dont think we need to make graphql-java a multi module code base to achieve this. I will grant that multi modulee allows you to better confirm
depedencies directions but its not essential. Its a lot easier to work on a single moduke code base for sure.
cc: @andimarek