Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Mar 22, 2024
1 parent 9acedf8 commit e558091
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/__tests__/__snapshots__/parser.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ exports[`parse > parses the kitchen sink document like graphql.js does 1`] = `
"selectionSet": undefined,
},
{
"arguments": [],
"arguments": undefined,
"directives": [
{
"arguments": [],
Expand Down Expand Up @@ -645,8 +645,7 @@ exports[`parse > parses the kitchen sink document like graphql.js does 1`] = `
"value": {
"block": true,
"kind": "StringValue",
"value": "block string uses """
",
"value": "block string uses """",
},
},
],
Expand Down
3 changes: 1 addition & 2 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,10 @@ export type FragmentSpreadNode = Or<
{
readonly kind: Kind.FRAGMENT_SPREAD;
readonly name: NameNode;
readonly arguments?: ReadonlyArray<ArgumentNode>;
readonly directives?: ReadonlyArray<DirectiveNode>;
readonly loc?: Location;
}
>;
> & { readonly arguments?: ReadonlyArray<ArgumentNode> };

export type InlineFragmentNode = Or<
GraphQL.InlineFragmentNode,
Expand Down
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ function fragmentSpread(): ast.FragmentSpreadNode | ast.InlineFragmentNode | und
kind: 'FragmentSpread' as Kind.FRAGMENT_SPREAD,
name: _name,
directives: directives(false),
arguments: _arguments,
arguments: _arguments.length ? _arguments : undefined,
};
} else {
idx = _idx;
Expand Down
3 changes: 2 additions & 1 deletion src/printer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ const nodes: {
},
FragmentSpread(node) {
let out = '...' + node.name.value;
if (hasItems(node.arguments)) out += '(' + node.arguments.map(nodes.Argument!).join(', ') + ')';
if ('arguments' in node && Array.isArray(node.arguments) && hasItems(node.arguments))
out += '(' + node.arguments.map(nodes.Argument!).join(', ') + ')';
if (hasItems(node.directives)) out += ' ' + node.directives.map(nodes.Directive!).join(' ');
return out;
},
Expand Down

0 comments on commit e558091

Please sign in to comment.