-
Notifications
You must be signed in to change notification settings - Fork 666
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
Add inline classes support for scalars #6352
Closed
Closed
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c35180b
Add inline classes support for scalars
BoD 26961bc
Add @inlineClass directive and generate inline class when present
BoD 902bc0c
Add scalar mapping when using @inlineClass
BoD 4c76ef2
Move @inlineClass to kotlin_labs/v0.5
BoD 947e017
Keep ScalarInfo binary compatible
BoD 35db1d9
Mark new APIs as @ApolloExperimental
BoD 1f0f4e5
Wording
BoD cf19811
Update libraries/apollo-compiler/src/main/kotlin/com/apollographql/ap…
BoD eb43a05
Remove `mapScalarToKotlinXyz` overrides.
BoD 0d53631
Add a few more tests
BoD b1051fb
IntelliJ plugin: be aware of latest kotlin-labs version
BoD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ enum class TargetLanguage { | |
/** | ||
* Base language version. | ||
*/ | ||
@Deprecated("Use KOTLIN_1_9 instead" , ReplaceWith("KOTLIN_1_9")) | ||
@Deprecated("Use KOTLIN_1_9 instead", ReplaceWith("KOTLIN_1_9")) | ||
@ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_2) | ||
KOTLIN_1_5, | ||
|
||
|
@@ -244,13 +244,15 @@ interface CommonCodegenOpt { | |
* Default: false | ||
*/ | ||
val decapitalizeFields: Boolean? | ||
|
||
/** | ||
* When true, the operation class names are suffixed with their operation type like ('Query', 'Mutation' ot 'Subscription'). | ||
* For an example, `query getDroid { ... }` GraphQL query generates the 'GetDroidQuery' class. | ||
* | ||
* Default value: true | ||
*/ | ||
val useSemanticNaming: Boolean? | ||
|
||
/** | ||
* Specifies which methods will be auto generated on operations, models, fragments and input objects. | ||
* | ||
|
@@ -332,6 +334,7 @@ interface SchemaCodegenOpt { | |
* Default: false | ||
*/ | ||
val generateSchema: Boolean? | ||
|
||
/** | ||
* Class name to use when generating the Schema class. | ||
* | ||
|
@@ -435,10 +438,12 @@ interface KotlinCodegenOpt { | |
* on servers | ||
*/ | ||
val addUnknownForEnums: Boolean? | ||
|
||
/** | ||
* Whether to add default arguments for input objects. | ||
*/ | ||
val addDefaultArgumentForInputObjects: Boolean? | ||
|
||
/** | ||
* Kotlin native generates [Any?] for optional types | ||
* Setting generateFilterNotNull generates extra `filterNotNull` functions that help keep the type information. | ||
|
@@ -487,10 +492,10 @@ interface KotlinCodegenOpt { | |
val jsExport: Boolean? | ||
} | ||
|
||
interface JavaOperationsCodegenOptions: CommonCodegenOpt, OperationsCodegenOpt, JavaCodegenOpt | ||
interface KotlinOperationsCodegenOptions: CommonCodegenOpt, OperationsCodegenOpt, KotlinCodegenOpt | ||
interface JavaSchemaCodegenOptions: CommonCodegenOpt, SchemaCodegenOpt, JavaCodegenOpt | ||
interface KotlinSchemaCodegenOptions: CommonCodegenOpt, SchemaCodegenOpt, KotlinCodegenOpt | ||
interface JavaOperationsCodegenOptions : CommonCodegenOpt, OperationsCodegenOpt, JavaCodegenOpt | ||
interface KotlinOperationsCodegenOptions : CommonCodegenOpt, OperationsCodegenOpt, KotlinCodegenOpt | ||
interface JavaSchemaCodegenOptions : CommonCodegenOpt, SchemaCodegenOpt, JavaCodegenOpt | ||
interface KotlinSchemaCodegenOptions : CommonCodegenOpt, SchemaCodegenOpt, KotlinCodegenOpt | ||
Comment on lines
+495
to
+498
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
interface SchemaCodegenOptions : JavaSchemaCodegenOptions, KotlinSchemaCodegenOptions | ||
interface OperationsCodegenOptions : JavaOperationsCodegenOptions, KotlinOperationsCodegenOptions | ||
|
@@ -521,7 +526,7 @@ class CodegenOptions( | |
override val nullableFieldStyle: JavaNullable?, | ||
override val generateFragmentImplementations: Boolean?, | ||
override val generateQueryDocument: Boolean?, | ||
): SchemaCodegenOptions, OperationsCodegenOptions | ||
) : SchemaCodegenOptions, OperationsCodegenOptions | ||
|
||
fun buildCodegenOptions( | ||
targetLanguage: TargetLanguage? = null, | ||
|
@@ -637,18 +642,33 @@ class ExpressionAdapterInitializer(val expression: String) : AdapterInitializer | |
object RuntimeAdapterInitializer : AdapterInitializer | ||
|
||
@Serializable | ||
class ScalarInfo( | ||
class ScalarInfo | ||
@ApolloExperimental | ||
constructor( | ||
val targetName: String, | ||
val adapterInitializer: AdapterInitializer = RuntimeAdapterInitializer, | ||
val userDefined: Boolean = true, | ||
) | ||
|
||
/** | ||
* If the target is an inline class, the property to access the underlying value, `null` otherwise. | ||
*/ | ||
@ApolloExperimental | ||
val inlineClassProperty: String? = null, | ||
) { | ||
constructor( | ||
targetName: String, | ||
adapterInitializer: AdapterInitializer = RuntimeAdapterInitializer, | ||
userDefined: Boolean = true, | ||
) : this(targetName, adapterInitializer, userDefined, null) | ||
} | ||
|
||
private val NoOpLogger = object : ApolloCompiler.Logger { | ||
override fun warning(message: String) { | ||
} | ||
} | ||
|
||
internal val defaultAlwaysGenerateTypesMatching = emptySet<String>() | ||
|
||
@Suppress("DEPRECATION") | ||
internal val defaultOperationOutputGenerator = OperationOutputGenerator.Default(OperationIdGenerator.Sha256) | ||
internal val defaultLogger = NoOpLogger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice!
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.
Also reminder to add the matching definition on https://github.com/apollographql/specs if we agree on this
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.
Also reminder to add support in the IDE plugin