-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #479 from jbaxleyiii/support-interfaces-in-mapped-…
…types Support type mapping when implementing an interface
- Loading branch information
Showing
23 changed files
with
399 additions
and
6 deletions.
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
11 changes: 11 additions & 0 deletions
11
...com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/DgsClient.kt
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected | ||
|
||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
import com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.client.QueryProjection | ||
import graphql.language.OperationDefinition | ||
import kotlin.String | ||
|
||
public object DgsClient { | ||
public fun buildQuery(_projection: QueryProjection.() -> QueryProjection): String = | ||
GraphQLProjection.asQuery(OperationDefinition.Operation.QUERY, QueryProjection(), _projection) | ||
} |
31 changes: 31 additions & 0 deletions
31
.../netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/DgsConstants.kt
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected | ||
|
||
import kotlin.String | ||
|
||
public object DgsConstants { | ||
public const val QUERY_TYPE: String = "Query" | ||
|
||
public object QUERY { | ||
public const val TYPE_NAME: String = "Query" | ||
|
||
public const val Products: String = "products" | ||
} | ||
|
||
public object PRODUCT { | ||
public const val TYPE_NAME: String = "Product" | ||
|
||
public const val Id: String = "id" | ||
} | ||
|
||
public object NODE { | ||
public const val TYPE_NAME: String = "Node" | ||
|
||
public const val Id: String = "id" | ||
} | ||
|
||
public object ENTITY { | ||
public const val TYPE_NAME: String = "Entity" | ||
|
||
public const val Id: String = "id" | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...aphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/EntityProjection.kt
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.client | ||
|
||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class EntityProjection : GraphQLProjection() { | ||
public val id: EntityProjection | ||
get() { | ||
field("id") | ||
return this | ||
} | ||
|
||
public fun onProduct(_projection: ProductProjection.() -> ProductProjection): EntityProjection { | ||
fragment("Product", ProductProjection(), _projection) | ||
return this | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/NodeProjection.kt
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.client | ||
|
||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class NodeProjection : GraphQLProjection() { | ||
public val id: NodeProjection | ||
get() { | ||
field("id") | ||
return this | ||
} | ||
|
||
public fun onEntity(_projection: EntityProjection.() -> EntityProjection): NodeProjection { | ||
fragment("Entity", EntityProjection(), _projection) | ||
return this | ||
} | ||
|
||
public fun onProduct(_projection: ProductProjection.() -> ProductProjection): NodeProjection { | ||
fragment("Product", ProductProjection(), _projection) | ||
return this | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...phql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/ProductProjection.kt
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.client | ||
|
||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class ProductProjection : GraphQLProjection() { | ||
public val id: ProductProjection | ||
get() { | ||
field("id") | ||
return this | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...raphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/client/QueryProjection.kt
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.client | ||
|
||
import com.netflix.graphql.dgs.codegen.GraphQLProjection | ||
|
||
public class QueryProjection : GraphQLProjection() { | ||
public fun products(_projection: ProductProjection.() -> ProductProjection): QueryProjection { | ||
field("products", ProductProjection(), _projection) | ||
return this | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/types/Entity.kt
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonSubTypes | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import com.netflix.graphql.dgs.codegen.fixtures.Node | ||
import kotlin.String | ||
import kotlin.Suppress | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.NAME, | ||
include = JsonTypeInfo.As.PROPERTY, | ||
property = "__typename", | ||
) | ||
@JsonSubTypes(value = [ | ||
JsonSubTypes.Type(value = Product::class, name = "Product") | ||
]) | ||
public sealed interface Entity : Node { | ||
@Suppress("INAPPLICABLE_JVM_NAME") | ||
@get:JvmName("getId") | ||
public override val id: String | ||
} |
46 changes: 46 additions & 0 deletions
46
...netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/types/Product.kt
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonIgnoreProperties | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize | ||
import com.fasterxml.jackson.databind.`annotation`.JsonPOJOBuilder | ||
import com.netflix.graphql.dgs.codegen.fixtures.Node | ||
import java.lang.IllegalStateException | ||
import kotlin.String | ||
import kotlin.Suppress | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = Product.Builder::class) | ||
public class Product( | ||
id: () -> String = idDefault, | ||
) : Entity, Node { | ||
private val _id: () -> String = id | ||
|
||
@Suppress("INAPPLICABLE_JVM_NAME") | ||
@get:JvmName("getId") | ||
public override val id: String | ||
get() = _id.invoke() | ||
|
||
public companion object { | ||
private val idDefault: () -> String = | ||
{ throw IllegalStateException("Field `id` was not requested") } | ||
|
||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var id: () -> String = idDefault | ||
|
||
@JsonProperty("id") | ||
public fun withId(id: String): Builder = this.apply { | ||
this.id = { id } | ||
} | ||
|
||
public fun build() = Product( | ||
id = id, | ||
) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...m/netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/expected/types/Query.kt
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.netflix.graphql.dgs.codegen.cases.dataClassWithMappedInterfaces.expected.types | ||
|
||
import com.fasterxml.jackson.`annotation`.JsonIgnoreProperties | ||
import com.fasterxml.jackson.`annotation`.JsonProperty | ||
import com.fasterxml.jackson.`annotation`.JsonTypeInfo | ||
import com.fasterxml.jackson.databind.`annotation`.JsonDeserialize | ||
import com.fasterxml.jackson.databind.`annotation`.JsonPOJOBuilder | ||
import java.lang.IllegalStateException | ||
import kotlin.collections.List | ||
import kotlin.jvm.JvmName | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE) | ||
@JsonDeserialize(builder = Query.Builder::class) | ||
public class Query( | ||
products: () -> List<Product?>? = productsDefault, | ||
) { | ||
private val _products: () -> List<Product?>? = products | ||
|
||
@get:JvmName("getProducts") | ||
public val products: List<Product?>? | ||
get() = _products.invoke() | ||
|
||
public companion object { | ||
private val productsDefault: () -> List<Product?>? = | ||
{ throw IllegalStateException("Field `products` was not requested") } | ||
|
||
} | ||
|
||
@JsonPOJOBuilder | ||
@JsonIgnoreProperties("__typename") | ||
public class Builder { | ||
private var products: () -> List<Product?>? = productsDefault | ||
|
||
@JsonProperty("products") | ||
public fun withProducts(products: List<Product?>?): Builder = this.apply { | ||
this.products = { products } | ||
} | ||
|
||
public fun build() = Query( | ||
products = products, | ||
) | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...kotlin/com/netflix/graphql/dgs/codegen/cases/dataClassWithMappedInterfaces/schema.graphql
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
type Query { | ||
products: [Product] | ||
} | ||
|
||
interface Node { | ||
id: ID! | ||
} | ||
|
||
interface Entity implements Node { | ||
id: ID! | ||
} | ||
|
||
type Product implements Entity & Node { | ||
id: ID! | ||
} |
23 changes: 23 additions & 0 deletions
23
...ql-dgs-codegen-core/src/integTest/kotlin/com/netflix/graphql/dgs/codegen/fixtures/Node.kt
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.netflix.graphql.dgs.codegen.fixtures | ||
|
||
interface Node { | ||
val id: String | ||
} |
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
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.