mirror of
https://github.com/graphql-hive/console
synced 2026-05-23 09:08:34 +00:00
fix: skip visiting directive arguments when collecting usage (#1224)
This commit is contained in:
parent
de7ba835e4
commit
cf14c18d6e
3 changed files with 39 additions and 0 deletions
5
.changeset/many-jobs-perform.md
Normal file
5
.changeset/many-jobs-perform.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@graphql-hive/client': minor
|
||||
---
|
||||
|
||||
skip directive arguments during usage collection
|
||||
|
|
@ -379,6 +379,12 @@ export function createCollector({
|
|||
collectInputType(resolveTypeName(inputType));
|
||||
}
|
||||
},
|
||||
Directive(node) {
|
||||
return {
|
||||
...node,
|
||||
arguments: [],
|
||||
};
|
||||
},
|
||||
Argument(node) {
|
||||
const parent = typeInfo.getParentType()!;
|
||||
const field = typeInfo.getFieldDef()!;
|
||||
|
|
|
|||
|
|
@ -195,6 +195,34 @@ test('collect arguments', async () => {
|
|||
expect(info.fields).toContain(`Query.projects.filter`);
|
||||
});
|
||||
|
||||
test('skips argument directives', async () => {
|
||||
const collect = createCollector({
|
||||
schema,
|
||||
max: 1,
|
||||
});
|
||||
const info = collect(
|
||||
parse(/* GraphQL */ `
|
||||
query getProjects($limit: Int!, $type: ProjectType!, $includeName: Boolean!) {
|
||||
projects(filter: { pagination: { limit: $limit }, type: $type }) {
|
||||
id
|
||||
...NestedFragment
|
||||
}
|
||||
}
|
||||
|
||||
fragment NestedFragment on Project {
|
||||
...IncludeNameFragment @include(if: $includeName)
|
||||
}
|
||||
|
||||
fragment IncludeNameFragment on Project {
|
||||
name
|
||||
}
|
||||
`),
|
||||
{},
|
||||
).value;
|
||||
|
||||
expect(info.fields).toContain(`Query.projects.filter`);
|
||||
});
|
||||
|
||||
test('collect used-only input fields', async () => {
|
||||
const collect = createCollector({
|
||||
schema,
|
||||
|
|
|
|||
Loading…
Reference in a new issue