Skip to content

Commit bd24417

Browse files
authored
Fix doubled whitespace for inline fragments (#355)
1 parent bb2fc47 commit bd24417

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,26 @@ jobs:
1818
with:
1919
show-progress: false
2020

21-
- name: Setup .NET SDK
22-
uses: actions/setup-dotnet@v3
23-
with:
24-
dotnet-version: 7.0.x
25-
26-
- name: Initialize CodeQL
27-
uses: github/codeql-action/init@v2
28-
with:
29-
queries: security-and-quality
30-
languages: csharp
31-
32-
- name: Install dependencies
33-
working-directory: src
34-
run: dotnet restore
35-
36-
- name: Build only parser project
37-
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/troubleshooting-the-codeql-workflow#reduce-the-amount-of-code-being-analyzed-in-a-single-workflow
38-
working-directory: src/GraphQLParser
39-
run: dotnet build --no-restore
40-
41-
- name: Perform CodeQL Analysis
42-
uses: github/codeql-action/analyze@v2
21+
- name: Setup .NET SDK
22+
uses: actions/setup-dotnet@v3
23+
with:
24+
dotnet-version: 7.0.x
25+
26+
- name: Initialize CodeQL
27+
uses: github/codeql-action/init@v2
28+
with:
29+
queries: security-and-quality
30+
languages: csharp
31+
config-file: ./.github/codeql-config.yml
32+
33+
- name: Install dependencies
34+
working-directory: src
35+
run: dotnet restore
36+
37+
- name: Build only parser project
38+
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/troubleshooting-the-codeql-workflow#reduce-the-amount-of-code-being-analyzed-in-a-single-workflow
39+
working-directory: src/GraphQLParser
40+
run: dotnet build --no-restore
41+
42+
- name: Perform CodeQL Analysis
43+
uses: github/codeql-action/analyze@v2

src/GraphQLParser.Tests/Visitors/SDLSorterTests.SortsSchemaDefinition.approved.ExecutableSortTests.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
field1(arg1: [3, 1, 2], arg2: "value1", arg3: {sub1: 2, sub2: 1, sub3: 3})
66
field2
77
field3 @dir1(arg1: [3, 1, 2], arg2: "value1", arg3: {sub1: 2, sub2: 1, sub3: 3}) @dir2 @dir3
8-
... {
8+
... {
99
field4
1010
}
1111
... on Type2 {

src/GraphQLParser.Tests/Visitors/SDLSorterTests.SortsSchemaDefinition.approved.KitchenSink.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
query queryName($foo: ComplexType, $site: Site = MOBILE) {
1313
whoever123is: node(id: [123, 456]) {
1414
id
15-
... @skip(unless: $foo) {
15+
... @skip(unless: $foo) {
1616
id
1717
}
18-
... {
18+
... {
1919
id
2020
}
2121
... on User @defer {

src/GraphQLParser/Visitors/SDLPrinter.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ protected override async ValueTask VisitFragmentDefinitionAsync(GraphQLFragmentD
206206
await VisitAsync(fragmentDefinition.Comments, context).ConfigureAwait(false);
207207
await context.WriteAsync("fragment ").ConfigureAwait(false);
208208
await VisitAsync(fragmentDefinition.FragmentName, context).ConfigureAwait(false);
209-
await context.WriteAsync(" ").ConfigureAwait(false);
210209
await VisitAsync(fragmentDefinition.TypeCondition, context).ConfigureAwait(false);
211210
await VisitAsync(fragmentDefinition.Directives, context).ConfigureAwait(false);
212211
await VisitAsync(fragmentDefinition.SelectionSet, context).ConfigureAwait(false);
@@ -234,7 +233,7 @@ protected override async ValueTask VisitInlineFragmentAsync(GraphQLInlineFragmen
234233

235234
await WriteIndentAsync(context).ConfigureAwait(false);
236235

237-
await context.WriteAsync("... ").ConfigureAwait(false);
236+
await context.WriteAsync("...").ConfigureAwait(false);
238237
await VisitAsync(inlineFragment.TypeCondition, context).ConfigureAwait(false);
239238
await VisitAsync(inlineFragment.Directives, context).ConfigureAwait(false);
240239
await VisitAsync(inlineFragment.SelectionSet, context).ConfigureAwait(false);
@@ -244,7 +243,7 @@ protected override async ValueTask VisitInlineFragmentAsync(GraphQLInlineFragmen
244243
protected override async ValueTask VisitTypeConditionAsync(GraphQLTypeCondition typeCondition, TContext context)
245244
{
246245
await VisitAsync(typeCondition.Comments, context).ConfigureAwait(false);
247-
await context.WriteAsync("on ").ConfigureAwait(false);
246+
await context.WriteAsync(TryPeekParent(context, out _) ? " on " : "on ").ConfigureAwait(false);
248247
await VisitAsync(typeCondition.Type, context).ConfigureAwait(false);
249248
}
250249

@@ -1117,8 +1116,8 @@ private static async ValueTask WriteIndentAsync(TContext context)
11171116
await context.WriteAsync(" ").ConfigureAwait(false);
11181117
}
11191118

1120-
// Returns parent if called inside ViisitXXX i.e. after context.Parents.Push(node);
1121-
// Returns grand-parent if called inside ViisitAsync i.e. before context.Parents.Push(node);
1119+
// Returns parent if called inside VisitXXX i.e. after context.Parents.Push(node);
1120+
// Returns grand-parent if called inside VisitAsync i.e. before context.Parents.Push(node);
11221121
private static bool TryPeekParent(TContext context, [NotNullWhen(true)] out ASTNode? node)
11231122
{
11241123
node = null;

0 commit comments

Comments
 (0)