-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Fusion composition tests for @deprecated merging
- Loading branch information
1 parent
9da664a
commit 9cf368a
Showing
6 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
136 changes: 136 additions & 0 deletions
136
src/HotChocolate/Fusion/test/Composition.Tests/DeprecationMergeTests.cs
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,136 @@ | ||
using Xunit.Abstractions; | ||
|
||
namespace HotChocolate.Fusion.Composition; | ||
|
||
public class DeprecationMergeTests(ITestOutputHelper output) : CompositionTestBase(output) | ||
{ | ||
[Fact] | ||
public async Task Merge_Entity_Output_Field_Deprecation() | ||
=> await Succeed( | ||
""" | ||
type Query { | ||
brandById(id: ID!): Brand | ||
} | ||
type Brand implements Node { | ||
id: ID! | ||
name: String! @deprecated(reason: "Some reason") | ||
} | ||
interface Node { | ||
id: ID! | ||
} | ||
""", | ||
""" | ||
type Query { | ||
brandById(id: ID!): Brand | ||
} | ||
type Brand implements Node { | ||
id: ID! | ||
newName: String! | ||
} | ||
interface Node { | ||
id: ID! | ||
} | ||
"""); | ||
|
||
[Fact] | ||
public async Task Merge_Entity_Output_Field_Argument_Deprecation() | ||
=> await Succeed( | ||
""" | ||
type Query { | ||
brandById(id: ID!): Brand | ||
} | ||
type Brand implements Node { | ||
id: ID! | ||
name(includeFirstName: Boolean @deprecated(reason: "Some reason")): String! | ||
} | ||
interface Node { | ||
id: ID! | ||
} | ||
""", | ||
""" | ||
type Query { | ||
brandById(id: ID!): Brand | ||
} | ||
type Brand implements Node { | ||
id: ID! | ||
name(includeFirstName: Boolean): String! | ||
} | ||
interface Node { | ||
id: ID! | ||
} | ||
"""); | ||
|
||
[Fact] | ||
public async Task Merge_Output_Field_Deprecation() | ||
=> await Succeed( | ||
""" | ||
type Query { | ||
brand: Brand | ||
} | ||
type Brand { | ||
name: String! @deprecated(reason: "Some reason") | ||
} | ||
""", | ||
""" | ||
type Query { | ||
brand: Brand | ||
} | ||
type Brand { | ||
newName: String! | ||
} | ||
"""); | ||
|
||
[Fact] | ||
public async Task Merge_Output_Field_Argument_Deprecation() | ||
=> await Succeed( | ||
""" | ||
type Query { | ||
brand: Brand | ||
} | ||
type Brand { | ||
name(includeFirstName: Boolean @deprecated(reason: "Some reason")): String! | ||
} | ||
""", | ||
""" | ||
type Query { | ||
brand: Brand | ||
} | ||
type Brand { | ||
name(includeFirstName: Boolean): String! | ||
} | ||
"""); | ||
|
||
[Fact] | ||
public async Task Merge_Enum_Value_Deprecation() | ||
=> await Succeed( | ||
""" | ||
type Query { | ||
value: OrderStatus | ||
} | ||
enum OrderStatus { | ||
SENT_OUT @deprecated(reason: "Some reason") | ||
} | ||
""", | ||
""" | ||
type Query { | ||
value: OrderStatus | ||
} | ||
enum OrderStatus { | ||
SHIPPED | ||
} | ||
"""); | ||
} |
34 changes: 34 additions & 0 deletions
34
..._snapshots__/DeprecationMergeTests.Merge_Entity_Output_Field_Argument_Deprecation.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,34 @@ | ||
schema | ||
@fusion(version: 1) | ||
@transport(subgraph: "A", location: "https:\/\/localhost:5001\/graphql", kind: "HTTP") | ||
@transport(subgraph: "B", location: "https:\/\/localhost:5002\/graphql", kind: "HTTP") { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
brandById(id: ID!): Brand | ||
@variable(subgraph: "A", name: "id", argument: "id") | ||
@resolver(subgraph: "A", select: "{ brandById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ]) | ||
@variable(subgraph: "B", name: "id", argument: "id") | ||
@resolver(subgraph: "B", select: "{ brandById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ]) | ||
} | ||
|
||
type Brand implements Node | ||
@variable(subgraph: "A", name: "Brand_id", select: "id") | ||
@variable(subgraph: "B", name: "Brand_id", select: "id") | ||
@resolver(subgraph: "A", select: "{ brandById(id: $Brand_id) }", arguments: [ { name: "Brand_id", type: "ID!" } ]) | ||
@resolver(subgraph: "B", select: "{ brandById(id: $Brand_id) }", arguments: [ { name: "Brand_id", type: "ID!" } ]) { | ||
id: ID! | ||
@source(subgraph: "A") | ||
@source(subgraph: "B") | ||
name(includeFirstName: Boolean | ||
@deprecated(reason: "Some reason")): String! | ||
@source(subgraph: "A") | ||
@variable(subgraph: "A", name: "includeFirstName", argument: "includeFirstName") | ||
@source(subgraph: "B") | ||
@variable(subgraph: "B", name: "includeFirstName", argument: "includeFirstName") | ||
} | ||
|
||
interface Node { | ||
id: ID! | ||
} |
33 changes: 33 additions & 0 deletions
33
...n.Tests/__snapshots__/DeprecationMergeTests.Merge_Entity_Output_Field_Deprecation.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,33 @@ | ||
schema | ||
@fusion(version: 1) | ||
@transport(subgraph: "A", location: "https:\/\/localhost:5001\/graphql", kind: "HTTP") | ||
@transport(subgraph: "B", location: "https:\/\/localhost:5002\/graphql", kind: "HTTP") { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
brandById(id: ID!): Brand | ||
@variable(subgraph: "A", name: "id", argument: "id") | ||
@resolver(subgraph: "A", select: "{ brandById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ]) | ||
@variable(subgraph: "B", name: "id", argument: "id") | ||
@resolver(subgraph: "B", select: "{ brandById(id: $id) }", arguments: [ { name: "id", type: "ID!" } ]) | ||
} | ||
|
||
type Brand implements Node | ||
@variable(subgraph: "A", name: "Brand_id", select: "id") | ||
@variable(subgraph: "B", name: "Brand_id", select: "id") | ||
@resolver(subgraph: "A", select: "{ brandById(id: $Brand_id) }", arguments: [ { name: "Brand_id", type: "ID!" } ]) | ||
@resolver(subgraph: "B", select: "{ brandById(id: $Brand_id) }", arguments: [ { name: "Brand_id", type: "ID!" } ]) { | ||
id: ID! | ||
@source(subgraph: "A") | ||
@source(subgraph: "B") | ||
name: String! | ||
@source(subgraph: "A") | ||
@deprecated(reason: "Some reason") | ||
newName: String! | ||
@source(subgraph: "B") | ||
} | ||
|
||
interface Node { | ||
id: ID! | ||
} |
20 changes: 20 additions & 0 deletions
20
...omposition.Tests/__snapshots__/DeprecationMergeTests.Merge_Enum_Value_Deprecation.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,20 @@ | ||
schema | ||
@fusion(version: 1) | ||
@transport(subgraph: "A", location: "https:\/\/localhost:5001\/graphql", kind: "HTTP") | ||
@transport(subgraph: "B", location: "https:\/\/localhost:5002\/graphql", kind: "HTTP") { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
value: OrderStatus | ||
@resolver(subgraph: "A", select: "{ value }") | ||
@resolver(subgraph: "B", select: "{ value }") | ||
} | ||
|
||
enum OrderStatus { | ||
SENT_OUT | ||
@source(subgraph: "A") | ||
@deprecated(reason: "Some reason") | ||
SHIPPED | ||
@source(subgraph: "B") | ||
} |
21 changes: 21 additions & 0 deletions
21
...Tests/__snapshots__/DeprecationMergeTests.Merge_Output_Field_Argument_Deprecation.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,21 @@ | ||
schema | ||
@fusion(version: 1) | ||
@transport(subgraph: "A", location: "https:\/\/localhost:5001\/graphql", kind: "HTTP") | ||
@transport(subgraph: "B", location: "https:\/\/localhost:5002\/graphql", kind: "HTTP") { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
brand: Brand | ||
@resolver(subgraph: "A", select: "{ brand }") | ||
@resolver(subgraph: "B", select: "{ brand }") | ||
} | ||
|
||
type Brand { | ||
name(includeFirstName: Boolean | ||
@deprecated(reason: "Some reason")): String! | ||
@source(subgraph: "A") | ||
@variable(subgraph: "A", name: "includeFirstName", argument: "includeFirstName") | ||
@source(subgraph: "B") | ||
@variable(subgraph: "B", name: "includeFirstName", argument: "includeFirstName") | ||
} |
20 changes: 20 additions & 0 deletions
20
...position.Tests/__snapshots__/DeprecationMergeTests.Merge_Output_Field_Deprecation.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,20 @@ | ||
schema | ||
@fusion(version: 1) | ||
@transport(subgraph: "A", location: "https:\/\/localhost:5001\/graphql", kind: "HTTP") | ||
@transport(subgraph: "B", location: "https:\/\/localhost:5002\/graphql", kind: "HTTP") { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
brand: Brand | ||
@resolver(subgraph: "A", select: "{ brand }") | ||
@resolver(subgraph: "B", select: "{ brand }") | ||
} | ||
|
||
type Brand { | ||
name: String! | ||
@source(subgraph: "A") | ||
@deprecated(reason: "Some reason") | ||
newName: String! | ||
@source(subgraph: "B") | ||
} |