|
1 |
| -using System.Diagnostics.CodeAnalysis; |
2 | 1 | using HotChocolate.Execution;
|
3 | 2 | using HotChocolate.Execution.Configuration;
|
4 |
| -using HotChocolate.Fusion.Configuration; |
5 |
| -using HotChocolate.Fusion.Execution; |
6 |
| -using HotChocolate.Fusion.Execution.Nodes; |
7 | 3 | using HotChocolate.Fusion.Logging;
|
8 |
| -using HotChocolate.Fusion.Planning; |
9 |
| -using HotChocolate.Fusion.Rewriters; |
10 |
| -using HotChocolate.Fusion.Types; |
11 |
| -using HotChocolate.Language; |
12 | 4 | using Microsoft.AspNetCore.Builder;
|
13 | 5 | using Microsoft.AspNetCore.TestHost;
|
14 | 6 | using Microsoft.Extensions.DependencyInjection;
|
15 |
| -using Microsoft.Extensions.ObjectPool; |
16 | 7 |
|
17 | 8 | namespace HotChocolate.Fusion;
|
18 | 9 |
|
19 | 10 | public abstract class FusionTestBase : IDisposable
|
20 | 11 | {
|
21 |
| - private readonly TestServerSession _testServerSession = new(); |
| 12 | + internal readonly TestServerSession _testServerSession = new(); |
22 | 13 | private bool _disposed;
|
23 | 14 |
|
24 |
| - protected static FusionSchemaDefinition CreateCompositeSchema() |
25 |
| - { |
26 |
| - var compositeSchemaDoc = Utf8GraphQLParser.Parse(FileResource.Open("fusion1.graphql")); |
27 |
| - return FusionSchemaDefinition.Create(compositeSchemaDoc); |
28 |
| - } |
29 |
| - |
30 |
| - protected static FusionSchemaDefinition CreateCompositeSchema( |
31 |
| - [StringSyntax("graphql")] string schema) |
32 |
| - { |
33 |
| - var compositeSchemaDoc = Utf8GraphQLParser.Parse(schema); |
34 |
| - return FusionSchemaDefinition.Create(compositeSchemaDoc); |
35 |
| - } |
36 |
| - |
37 |
| - protected static FusionSchemaDefinition ComposeSchema( |
38 |
| - [StringSyntax("graphql")] params string[] schemas) |
39 |
| - { |
40 |
| - var compositionLog = new CompositionLog(); |
41 |
| - var composer = new SchemaComposer(schemas, compositionLog); |
42 |
| - var result = composer.Compose(); |
43 |
| - |
44 |
| - if (!result.IsSuccess) |
45 |
| - { |
46 |
| - throw new InvalidOperationException(result.Errors[0].Message); |
47 |
| - } |
48 |
| - |
49 |
| - var compositeSchemaDoc = result.Value.ToSyntaxNode(); |
50 |
| - return FusionSchemaDefinition.Create(compositeSchemaDoc); |
51 |
| - } |
52 |
| - |
53 |
| - protected static DocumentNode ComposeSchemaDocument( |
54 |
| - [StringSyntax("graphql")] params string[] schemas) |
55 |
| - { |
56 |
| - var compositionLog = new CompositionLog(); |
57 |
| - var composer = new SchemaComposer(schemas, compositionLog); |
58 |
| - var result = composer.Compose(); |
59 |
| - |
60 |
| - if (!result.IsSuccess) |
61 |
| - { |
62 |
| - throw new InvalidOperationException(result.Errors[0].Message); |
63 |
| - } |
64 |
| - |
65 |
| - return result.Value.ToSyntaxNode(); |
66 |
| - } |
67 |
| - |
68 | 15 | public TestServer CreateSourceSchema(
|
69 | 16 | string schemaName,
|
70 | 17 | Action<IRequestExecutorBuilder> configureBuilder,
|
@@ -141,33 +88,6 @@ public async Task<TestServer> CreateCompositeSchemaAsync(
|
141 | 88 | configureApplication);
|
142 | 89 | }
|
143 | 90 |
|
144 |
| - protected static OperationExecutionPlan PlanOperation( |
145 |
| - FusionSchemaDefinition schema, |
146 |
| - [StringSyntax("graphql")] string operationText) |
147 |
| - { |
148 |
| - var pool = new DefaultObjectPool<OrderedDictionary<string, List<FieldSelectionNode>>>( |
149 |
| - new DefaultPooledObjectPolicy<OrderedDictionary<string, List<FieldSelectionNode>>>()); |
150 |
| - |
151 |
| - var operationDoc = Utf8GraphQLParser.Parse(operationText); |
152 |
| - |
153 |
| - var rewriter = new InlineFragmentOperationRewriter(schema); |
154 |
| - var rewritten = rewriter.RewriteDocument(operationDoc, operationName: null); |
155 |
| - var operation = rewritten.Definitions.OfType<OperationDefinitionNode>().First(); |
156 |
| - |
157 |
| - var compiler = new OperationCompiler(schema, pool); |
158 |
| - var planner = new OperationPlanner(schema, compiler); |
159 |
| - return planner.CreatePlan("123", operation); |
160 |
| - } |
161 |
| - |
162 |
| - protected static void MatchInline( |
163 |
| - OperationExecutionPlan plan, |
164 |
| - [StringSyntax("yaml")] string expected) |
165 |
| - { |
166 |
| - var formatter = new YamlExecutionPlanFormatter(); |
167 |
| - var actual = formatter.Format(plan); |
168 |
| - actual.MatchInlineSnapshot(expected + Environment.NewLine); |
169 |
| - } |
170 |
| - |
171 | 91 | public void Dispose()
|
172 | 92 | {
|
173 | 93 | if (_disposed)
|
|
0 commit comments