-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relaxing `@requires` and `@external` constraints. Previously ALL fields referenced from the `@requires` selection set had to be marked `@external`. This was too strict as it is possible to define `@requires` selection set against **local** object type with some `@external` fields. As a result only leaf fields (i.e. scalar/enum fields) have to be explicitly marked `@external` OR implicitly inherit `@external` characteristic through any of the leaf field ancestors.
- Loading branch information
1 parent
98e900e
commit 5cad531
Showing
8 changed files
with
248 additions
and
23 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
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
49 changes: 49 additions & 0 deletions
49
...iagroup/graphql/generator/federation/data/integration/requires/success/_5/LeafRequires.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,49 @@ | ||
/* | ||
* Copyright 2023 Expedia, 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 | ||
* | ||
* https://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.expediagroup.graphql.generator.federation.data.integration.requires.success._5 | ||
|
||
import com.expediagroup.graphql.generator.federation.directives.ExternalDirective | ||
import com.expediagroup.graphql.generator.federation.directives.FieldSet | ||
import com.expediagroup.graphql.generator.federation.directives.KeyDirective | ||
import com.expediagroup.graphql.generator.federation.directives.RequiresDirective | ||
import kotlin.properties.Delegates | ||
|
||
/* | ||
# only leaf fields have to be external when @requires references complex types | ||
type LeafRequires @key(fields : "id") { | ||
complexType: ComplexType! | ||
description: String! | ||
id: String! | ||
shippingCost: String! @requires(fields : "complexType { weight }") | ||
} | ||
type ComplexType { | ||
localField: String | ||
weight: Float! @external | ||
} | ||
*/ | ||
@KeyDirective(fields = FieldSet("id")) | ||
class LeafRequires(val id: String, val description: String, val complexType: ComplexType) { | ||
|
||
@RequiresDirective(FieldSet("complexType { weight }")) | ||
fun shippingCost(): String = "$${complexType.weight * 9.99}" | ||
} | ||
|
||
class ComplexType(val localField: String) { | ||
@ExternalDirective | ||
var weight: Double by Delegates.notNull() | ||
} |
48 changes: 48 additions & 0 deletions
48
...ql/generator/federation/data/integration/requires/success/_6/RecursiveExternalRequires.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,48 @@ | ||
/* | ||
* Copyright 2023 Expedia, 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 | ||
* | ||
* https://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.expediagroup.graphql.generator.federation.data.integration.requires.success._6 | ||
|
||
import com.expediagroup.graphql.generator.federation.directives.ExternalDirective | ||
import com.expediagroup.graphql.generator.federation.directives.FieldSet | ||
import com.expediagroup.graphql.generator.federation.directives.KeyDirective | ||
import com.expediagroup.graphql.generator.federation.directives.RequiresDirective | ||
import kotlin.properties.Delegates | ||
|
||
/* | ||
# @external information is applied recursively through parent fields | ||
type RecursiveExternalRequires @key(fields : "id") { | ||
complexType: ComplexType! @external | ||
description: String! | ||
id: String! | ||
shippingCost: String! @requires(fields : "complexType { weight }") | ||
} | ||
type ComplexType { | ||
potentiallyExternal: String | ||
weight: Float! | ||
} | ||
*/ | ||
@KeyDirective(fields = FieldSet("id")) | ||
class RecursiveExternalRequires(val id: String, val description: String, @ExternalDirective val complexType: ComplexType) { | ||
|
||
@RequiresDirective(FieldSet("complexType { weight }")) | ||
fun shippingCost(): String = "$${complexType.weight * 9.99}" | ||
} | ||
|
||
class ComplexType(val potentiallyExternal: String) { | ||
var weight: Double by Delegates.notNull() | ||
} |
49 changes: 49 additions & 0 deletions
49
...graphql/generator/federation/data/integration/requires/success/_7/ExternalRequiresType.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,49 @@ | ||
/* | ||
* Copyright 2023 Expedia, 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 | ||
* | ||
* https://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.expediagroup.graphql.generator.federation.data.integration.requires.success._7 | ||
|
||
import com.expediagroup.graphql.generator.federation.directives.ExternalDirective | ||
import com.expediagroup.graphql.generator.federation.directives.FieldSet | ||
import com.expediagroup.graphql.generator.federation.directives.KeyDirective | ||
import com.expediagroup.graphql.generator.federation.directives.RequiresDirective | ||
import kotlin.properties.Delegates | ||
|
||
/* | ||
# @external information is applied to fields within type | ||
type RecursiveExternalRequires @key(fields : "id") { | ||
externalType: ExternalType! | ||
description: String! | ||
id: String! | ||
shippingCost: String! @requires(fields : "complexType { weight }") | ||
} | ||
type ExternalType @external { | ||
allExternal: String | ||
weight: Float! | ||
} | ||
*/ | ||
@KeyDirective(fields = FieldSet("id")) | ||
class ExternalRequiresType(val id: String, val description: String, val externalType: ExternalType) { | ||
|
||
@RequiresDirective(FieldSet("externalType { weight }")) | ||
fun shippingCost(): String = "$${externalType.weight * 9.99}" | ||
} | ||
|
||
@ExternalDirective | ||
class ExternalType(val allExternal: String) { | ||
var weight: Double by Delegates.notNull() | ||
} |
Oops, something went wrong.