ardatan / ardatan/graphql-tools
Directive definition is changed from pruning.
- Dominant language
- TypeScript
- Stars
- 5.4k
- Forks
- 830
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 45
Description
### Issue workflow progress
_Progress of the issue based on the [Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_
- [ ] 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox
> Make sure to fork this template and run `yarn generate` in the terminal.
>
> Please make sure the GraphQL Tools package versions under `package.json` matches yours.
- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
---
**Describe the bug**
The `scalar _FieldSet` is removed from directive definition.
It's not breaking client because the graphql tool selectively prune unused types from a schema, but it removes parameter from directive definition. In this case, when the schema didn't use a directive, it will remove `scalar _FieldSet` from directive.
Removing directive's parameter alters its definition, and these `fields: _FieldSet!` is required for the directive. I think we should either keep the `fields: _FieldSet!` or remove directive completely so the definition remains correct in schema.
**To Reproduce**
[Codesandbox link](https://codesandbox.io/p/devbox/fervent-yonath-3she6c?file=%2Fsrc%2Findex.ts&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clqeatl0f001w3b6hwscrluu4%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clqeatl0e001t3b6h8z33txno%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clqeatl0e001v3b6h16waztrt%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clqeatl0e001u3b6hl40rpr20%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B44.16385303672486%252C55.83614696327514%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clqeatl0e001t3b6h8z33txno%2522%253A%257B%2522id%2522%253A%2522clqeatl0e001t3b6h8z33txno%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clpeeh64r00023b6hfplwiwe4%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fyarn.lock%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522cluikeder006o3b6ioo882w2l%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A3%252C%2522startColumn%2522%253A22%252C%2522endLineNumber%2522%253A3%252C%2522endColumn%2522%253A22%257D%255D%252C%2522filepath%2522%253A%2522%252Fpackage.json%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522cluikwmwb00023b6icd69nkdo%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252Fsrc%252Findex.ts%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522activeTabId%2522%253A%2522cluikwmwb00023b6icd69nkdo%2522%257D%252C%2522clqeatl0e001u3b6hl40rpr20%2522%253A%257B%2522id%2522%253A%2522clqeatl0e001u3b6hl40rpr20%2522%252C%2522tabs%2522%253A%255B%255D%257D%252C%2522clqeatl0e001v3b6h16waztrt%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clpeeh64r00043b6hi60pc60l%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522start%2522%257D%255D%252C%2522id%2522%253A%2522clqeatl0e001v3b6h16waztrt%2522%252C%2522activeTabId%2522%253A%2522clpeeh64r00043b6hi60pc60l%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)
**Expected behavior**
Do not remove types used in directive definition
**Environment:**
- OS: MacOS
- `@graphql-tools/utils`: 9.1.4
- NodeJS: 14
**Additional context**
Contributor guide
Research direction
Reproduce the schema-pruning behavior from the linked CodeSandbox, starting with src/index.ts and package.json to confirm the GraphQL Tools versions and inputs. Locate the pruning entry point, add coverage for directive argument types, and verify that unused types are not removed when referenced by a directive definition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100