Skip to content

Commit 05d8dd8

Browse files
committed
Fix print
1 parent 72eca4a commit 05d8dd8

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.claude/settings.local.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(npm test:*)",
5+
"Bash(npx vitest run:*)",
6+
"Bash(git add:*)",
7+
"Bash(git rebase:*)"
8+
],
9+
"deny": []
10+
}
11+
}

src/__tests__/printer.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe('print', () => {
190190
},
191191
arguments: [
192192
{
193-
kind: 'Argument',
193+
kind: 'FragmentArgument',
194194
name: {
195195
kind: 'Name',
196196
value: 'var',

src/printer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {
2424
NamedTypeNode,
2525
ListTypeNode,
2626
NonNullTypeNode,
27+
FragmentArgumentNode,
2728
} from './ast';
2829

2930
function mapJoin<T>(value: readonly T[], joiner: string, mapper: (value: T) => string): string {
@@ -47,7 +48,10 @@ const MAX_LINE_LENGTH = 80;
4748

4849
let LF = '\n';
4950

50-
function Arguments(length: number, node: readonly ArgumentNode[]): string {
51+
function Arguments(
52+
length: number,
53+
node: readonly ArgumentNode[] | readonly FragmentArgumentNode[]
54+
): string {
5155
const args = mapJoin(node, ', ', nodes.Argument);
5256
if (length + args.length + 2 > MAX_LINE_LENGTH) {
5357
return '(' + (LF += ' ') + mapJoin(node, LF, nodes.Argument) + (LF = LF.slice(0, -2)) + ')';
@@ -138,7 +142,7 @@ const nodes = {
138142
SelectionSet(node: SelectionSetNode): string {
139143
return '{' + (LF += ' ') + mapJoin(node.selections, LF, _print) + (LF = LF.slice(0, -2)) + '}';
140144
},
141-
Argument(node: ArgumentNode): string {
145+
Argument(node: ArgumentNode | FragmentArgumentNode): string {
142146
return node.name.value + ': ' + _print(node.value);
143147
},
144148
FragmentSpread(node: FragmentSpreadNode): string {

0 commit comments

Comments
 (0)