-
Notifications
You must be signed in to change notification settings - Fork 656
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
Generate Optional instead of null #322
Generate Optional instead of null #322
Conversation
@@ -4,6 +4,7 @@ import com.apollographql.android.api.graphql.Mutation | |||
import com.apollographql.android.api.graphql.Operation | |||
import com.apollographql.android.api.graphql.Query | |||
import com.apollographql.android.api.graphql.ResponseReader | |||
import com.apollographql.android.api.graphql.internal.Optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outside the scope of the PR, but I feel Optional shouldn't be in the internal
package since we're exposing that API to consumers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe external then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that or maybe util
or extension
since we're making the use of Optional
optional?
No preference, whatever works.
@marwanad could you pls review again I add new extension to our plugin to switch on/off Optional generation |
@@ -37,7 +40,11 @@ void generateClasses(IncrementalTaskInputs inputs) { | |||
inputs.outOfDate(new Action<InputFileDetails>() { | |||
@Override | |||
public void execute(InputFileDetails inputFileDetails) { | |||
new GraphQLCompiler().write(inputFileDetails.getFile(), outputDir, customTypeMapping, hasGuavaDep); | |||
NullableValueType nullableValueType = NullableValueType.NONE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if we keep this logic part of the compiler. I feel making this class as dummy as possible and just passing all the information to the compiler would make it easier and faster to test for one (no need for a separate integration test) alongside keeping the generation logic in one place.
Might as well create a data class GraphQLCompilerArgs
to wrap all the arguments and do these checks in GraphQLCompiler.write()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great - thanks for making optional use confirugable
Part of #290
Variables generation remains the same due to the plan of refactoring to simplify builder. So will be done in next PR.
Input object generation remains the same as they being used in serialization of request body via moshi.