-
-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced Require Directive (#6281)
- Loading branch information
1 parent
5f47bb8
commit 563600b
Showing
15 changed files
with
128 additions
and
85 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
13 changes: 13 additions & 0 deletions
13
src/HotChocolate/Fusion/src/Composition/Directives/RequireDirective.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,13 @@ | ||
using HotChocolate.Language; | ||
|
||
namespace HotChocolate.Fusion.Composition; | ||
|
||
internal sealed class RequireDirective | ||
{ | ||
public RequireDirective(FieldNode field) | ||
{ | ||
Field = field; | ||
} | ||
|
||
public FieldNode Field { get; } | ||
} |
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
6 changes: 6 additions & 0 deletions
6
src/HotChocolate/Fusion/src/Composition/Entities/MemberReference.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,6 @@ | ||
using HotChocolate.Language; | ||
using HotChocolate.Skimmed; | ||
|
||
namespace HotChocolate.Fusion.Composition; | ||
|
||
internal sealed record MemberReference(InputField Argument, FieldNode Requirement); |
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
6 changes: 6 additions & 0 deletions
6
src/HotChocolate/Fusion/src/Composition/Properties/CompositionResources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
56 changes: 56 additions & 0 deletions
56
src/HotChocolate/Fusion/test/Composition.Tests/RequireTests.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,56 @@ | ||
using CookieCrumble; | ||
using HotChocolate.Fusion.Shared; | ||
using HotChocolate.Skimmed.Serialization; | ||
using Xunit.Abstractions; | ||
using static HotChocolate.Fusion.Shared.DemoProjectSchemaExtensions; | ||
|
||
namespace HotChocolate.Fusion.Composition; | ||
|
||
public class RequireTests | ||
{ | ||
private readonly Func<ICompositionLog> _logFactory; | ||
|
||
public RequireTests(ITestOutputHelper output) | ||
{ | ||
_logFactory = () => new TestCompositionLog(output); | ||
} | ||
|
||
[Fact] | ||
public async Task Require_Scalar_Arguments_No_Overloads() | ||
{ | ||
// arrange | ||
using var demoProject = await DemoProject.CreateAsync(); | ||
|
||
var composer = new FusionGraphComposer(logFactory: _logFactory); | ||
|
||
var fusionConfig = await composer.ComposeAsync( | ||
new[] | ||
{ | ||
demoProject.Accounts.ToConfiguration(), | ||
demoProject.Reviews.ToConfiguration(), | ||
demoProject.Products.ToConfiguration( | ||
""" | ||
extend type Query { | ||
productById(id: ID! @is(field: "id")): Product | ||
} | ||
"""), | ||
demoProject.Shipping.ToConfiguration( | ||
""" | ||
extend type Query { | ||
productById(id: ID! @is(field: "id")): Product | ||
} | ||
extend type Product { | ||
deliveryEstimate( | ||
size: Int! @require(field: "dimension { size }"), | ||
weight: Int! @require(field: "dimension { weight }"), | ||
zip: String!): DeliveryEstimate! | ||
} | ||
"""), | ||
}); | ||
|
||
SchemaFormatter | ||
.FormatAsString(fusionConfig) | ||
.MatchSnapshot(extension: ".graphql"); | ||
} | ||
} |
File renamed without changes.
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
File renamed without changes.