graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

build(load-files): generic for `loadFilesSync` and `loadFiles`

Open jjangga0214 opened this issue 5 months ago • 1 comments

🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.

Description

  • loadFilesSync has generic while loadFiles. So generic is added to loadFiles.
  • Instead of <T = any>, <T = DocumentNode> is used, since they are mainly used for loading schema. This even makes it work with graphql-module.
import { createModule } from 'graphql-modules'

export default createModule({
  // `typeDefs` requires `DocumentNode[]`. 
  // Before, `loadFiles` caused type error as it's `any[]`. 
  // But by this PR, it works as expected.
  typeDefs: await loadFiles('...'),
})

Type of change

Please delete options that are not relevant.

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [?] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [x] This change requires a documentation update

Checklist:

  • [x] I have followed the CONTRIBUTING doc and the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests and linter rules pass locally with my changes
  • [x] Any dependent changes have been merged and published in downstream modules

jjangga0214 avatar Sep 09 '24 02:09 jjangga0214