Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dotansimha/graphql-code-generator-community
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @graphql-codegen/typescript-generic-sdk@4.0.0
Choose a base ref
...
head repository: dotansimha/graphql-code-generator-community
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @graphql-codegen/typescript-generic-sdk@4.0.1
Choose a head ref

Commits on Sep 26, 2023

  1. chore(deps): update dependency rimraf to v5.0.4 (#426)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Sep 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6d89bab View commit details
  2. tests pass (#404)

    khasbilegt authored Sep 26, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    44925e9 View commit details
  3. create changeset

    saihaj committed Sep 26, 2023
    Copy the full SHA
    df7683e View commit details

Commits on Oct 3, 2023

  1. chore(deps): update dependency @types/node to v18.18.3 (#436)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 3, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    66b414e View commit details

Commits on Oct 16, 2023

  1. chore(deps): update dependency lint-staged to v15 (#451)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f6fdb52 View commit details
  2. Feat/typescript vue apollo client id in config (#363)

    * feat(typescript-vue-apollo) add clientId to config
    
    * feat(typescript-vue-apollo) make prettier
    
    * feat(typescript-vue-apollo) added changeset
    
    * Update packages/plugins/typescript/vue-apollo/src/visitor.ts
    
    Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
    
    ---------
    
    Co-authored-by: Soenke Wunderlich <soenke.wunderlich@dreamit.de>
    Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
    3 people authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8e829d5 View commit details
  3. chore(deps): update dependency @apollo/client to v3.8.6 (#442)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2dd3167 View commit details
  4. chore(deps): update babel monorepo to v7.23.2 (#450)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    07caae6 View commit details
  5. chore(deps): update dependency eslint to v8.51.0 (#443)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2e16874 View commit details
  6. chore(deps): update dependency @types/node to v18.18.5 (#444)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    cdffdd1 View commit details
  7. fix(deps): update dependency @graphql-tools/utils to v10.0.7 (#447)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    72666f1 View commit details
  8. chore(deps): update dependency rimraf to v5.0.5 (#432)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e75d2fc View commit details
  9. chore(deps): update dependency @reduxjs/toolkit to v1.9.7 (#440)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 16, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d448b47 View commit details

Commits on Oct 19, 2023

  1. chore(deps): update dependency @types/pluralize to v0.0.32 (#459)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7b83a3c View commit details
  2. chore(deps): update dependency @types/parse-filepath to v1.0.1 (#457)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    96f08ff View commit details
  3. chore(deps): update dependency @types/lodash to v4.14.200 (#455)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    47c3d73 View commit details
  4. chore(deps): update dependency @types/node to v18.18.6 (#456)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    492ab32 View commit details
  5. feat(hasura-allow-list):add config to change fragments definition ord…

    …er (#452)
    
    * feat(hasura-allow-list):add config to change fragments definition order
    
    * Create long-zebras-perform.md
    
    ---------
    
    Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
    shoma-mano and saihaj authored Oct 19, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0fea1a8 View commit details

Commits on Oct 24, 2023

  1. chore(deps): update dependency node to v20 (#470)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 24, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    40cafe9 View commit details
  2. chore(deps): update dependency eslint-plugin-import to v2.29.0 (#466)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 24, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d6ec42d View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f717055 View commit details

Commits on Oct 25, 2023

  1. feat : [typescript-react-apollo] support useSuspenseQuery (#392)

    * Implmement useSuspenseQuery in _buildHooks
    
    * Revert updated code from prettier
    
    * Update yarn
    
    * Update test codes for the added useSuspenseQuery
    
    * Revert "Update yarn"
    
    This reverts commit dc7462b.
    
    * Update prettier
    
    * Update snapshot
    
    * Update snapshot
    
    * Generate dev-test examples
    
    * Update types.react-query
    
    * Create neat-sheep-protect.md
    
    ---------
    
    Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
    Hal-ang and saihaj authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d86d205 View commit details
  2. Update neat-sheep-protect.md

    saihaj authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6d623a0 View commit details
  3. chore(deps): update dependency eslint to v8.52.0 (#461)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    45a5bf1 View commit details
  4. chore(deps): update dependency lint-staged to v15.0.2 (#460)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b60e13c View commit details
  5. Allows versions 6.x of graphql-request to be used. (#449)

    * Allows versions 6.x of graphql-request to be used.
    
    * Create nervous-apricots-dream.md
    
    ---------
    
    Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
    colinsullivan and saihaj authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    62420e5 View commit details
  6. feat(react-query): support react query v5 (#434)

    * refactor: formatQueryParameters
    
    * refactor: rename
    
    * refactor: generateFormattedMutationParameters
    
    * refactor: rename
    
    * refactor: generateInfiniteQueryFormattedParameters
    
    * feat: plugin config for support v5
    
    * fix: infiniteQuery option to required
    
    * fix: infinite query type
    
    * fix: Unnecessary semicolon
    
    * fix: test
    
    * refactor: use class inherent
    
    * fix: v5 parameters type
    
    * add: changeset
    
    * refactor: interface
    
    * fix: typo
    
    * refactor: queryHook
    
    * refactor: test & custom-mapper query
    
    * refactor: generateQuery
    
    * refactor: interface
    
    * refactor: type
    
    * refactor: type
    
    * refactor: fetcher-fetch mutation
    
    * refactor: fetch-hardcode mutation
    
    * refactor: fetch-graphql-request mutation
    
    * refactor: fetch-custom-mapper mutation
    
    * refactor: fetch-hardcode infiniteQuery
    
    * refactor: custom-mapper infiniteQuery
    
    * refactor: fetch infiniteQuery
    
    * refactor: graphql-request infiniteQuery
    
    * fix: v5 queryOptions queryKey type issue
    
    * refactor: move queryMethodMap to  private
    
    * fix: dev-test
    
    * fix: text break
    
    * edit: deprecated legacy mode flag
    
    * refactor: generate fn args format
    
    * add: v5 suspense support
    
    * refactor: dry
    
    * fix: suspense queryKey
    
    * fix: suspense optionsType
    
    * refactor: dry
    
    * refactor: format
    
    * fix: infiniteData type
    
    * Update packages/plugins/typescript/react-query/package.json
    
    ---------
    
    Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
    neil585456525 and saihaj authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    935b51f View commit details
  7. chore(release): update monorepo packages versions (#429)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Oct 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    04e3afe View commit details

Commits on Nov 9, 2023

  1. typescript-msw: future proof types for generated mock functions (#484)

    * future proof types for generated mock functions
    
    * fixes
    
    * prettier
    
    * changeset
    
    * Update tidy-trains-wait.md
    
    * test fixes
    
    * Apply suggestions from code review
    
    ---------
    
    Co-authored-by: Dotan Simha <dotansimha@gmail.com>
    Co-authored-by: Saihajpreet Singh <saihajpreet.singh@gmail.com>
    3 people authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1f056e9 View commit details
  2. chore(deps): update dependency @types/lodash to v4.14.201 (#488)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e429ad2 View commit details
  3. chore(deps): update dependency @types/pluralize to v0.0.33 (#486)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ceb5823 View commit details
  4. chore(deps): update dependency @types/parse-filepath to v1.0.2 (#485)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ded06f2 View commit details
  5. chore(deps): update dependency eslint to v8.53.0 (#480)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c0befce View commit details
  6. chore(deps): update dependency @apollo/client to v3.8.7 (#479)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2d2cb91 View commit details
  7. fix(deps): update dependency @graphql-tools/utils to v10.0.8 (#475)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    593909c View commit details
  8. chore(deps): update dependency @types/node to v20.9.0 (#473)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e289988 View commit details
  9. chore(release): update monorepo packages versions (#490)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    github-actions[bot] and github-actions[bot] authored Nov 9, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3c5ad05 View commit details

Commits on Nov 22, 2023

  1. chore(deps): update whatwg-node (#504)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 22, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    94a07af View commit details

Commits on Nov 23, 2023

  1. chore(deps): update graphql-tools (#508)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bdf4126 View commit details
  2. Update renovate.json

    ardatan authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8462d7b View commit details
  3. chore(deps): update typescript-eslint monorepo to v6 (#420)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    e58dd1f View commit details
  4. chore(deps): update dependency @types/lodash to v4.14.202 (#503)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f3ba842 View commit details
  5. chore(deps): update babel monorepo to v7.23.3 (#491)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    77ca2c2 View commit details
  6. chore(deps): update dependency eslint to v8.54.0 (#498)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0322df0 View commit details
  7. chore(deps): update dependency lint-staged to v15.1.0 (#492)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    b4e24bd View commit details
  8. chore(deps): update dependency @types/node to v20.9.4 (#497)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 23, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9bce019 View commit details

Commits on Nov 24, 2023

  1. chore(deps): update dependency @types/node to v20.9.5 (#510)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 24, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1af2d07 View commit details
  2. chore(deps): update dependency @types/node to v20.10.0 (#514)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 24, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    30ec454 View commit details

Commits on Nov 27, 2023

  1. chore(deps): update typescript-eslint monorepo to v6.13.0 (#518)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 27, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4a831fa View commit details

Commits on Nov 28, 2023

  1. chore(deps): update dependency @changesets/changelog-github to v0.5.0 (

    …#519)
    
    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Nov 28, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    357da81 View commit details
Showing with 9,564 additions and 2,536 deletions.
  1. +1 −1 .github/workflows/main.yml
  2. +1 −1 .nvmrc
  3. +4 −1 .vscode/settings.json
  4. +2 −0 README.md
  5. +9 −1 dev-test/codegen.ts
  6. +38 −18 dev-test/githunt/types.react-query.ts
  7. +32 −0 dev-test/githunt/types.reactApollo.customSuffix.tsx
  8. +75 −0 dev-test/githunt/types.reactApollo.hooks.tsx
  9. +29 −0 dev-test/githunt/types.reactApollo.preResolveTypes.tsx
  10. +29 −0 dev-test/githunt/types.reactApollo.tsx
  11. +32 −0 dev-test/githunt/types.reactApollo.v2.tsx
  12. +2 −2 dev-test/githunt/types.urql.tsx
  13. +2 −2 dev-test/githunt/types.vueApollo.ts
  14. +15 −0 dev-test/star-wars/__generated__/HeroAndFriendsNames.tsx
  15. +10 −0 dev-test/star-wars/__generated__/HeroAppearsIn.tsx
  16. +10 −0 dev-test/star-wars/__generated__/HeroDetails.tsx
  17. +15 −0 dev-test/star-wars/__generated__/HeroDetailsWithFragment.tsx
  18. +7 −0 dev-test/star-wars/__generated__/HeroName.tsx
  19. +30 −0 dev-test/star-wars/__generated__/HeroNameConditional.tsx
  20. +15 −0 dev-test/star-wars/__generated__/HeroParentTypeDependentField.tsx
  21. +15 −0 dev-test/star-wars/__generated__/HeroTypeDependentAliasedField.tsx
  22. +15 −0 dev-test/star-wars/__generated__/HumanWithNullWeight.tsx
  23. +10 −0 dev-test/star-wars/__generated__/TwoHeroes.tsx
  24. +142 −0 dev-test/star-wars/types.refetchFn.tsx
  25. +10 −0 dev-test/test-message/types.tsx
  26. +15 −15 package.json
  27. +1 −1 packages/plugins/java/apollo-android/package.json
  28. +9 −0 packages/plugins/java/kotlin/CHANGELOG.md
  29. +1 −1 packages/plugins/java/kotlin/package.json
  30. +1 −0 packages/plugins/java/kotlin/src/visitor.ts
  31. +46 −0 packages/plugins/java/kotlin/tests/kotlin.spec.ts
  32. +9 −0 packages/plugins/other/hasura-allow-list/CHANGELOG.md
  33. +1 −1 packages/plugins/other/hasura-allow-list/package.json
  34. +5 −0 packages/plugins/other/hasura-allow-list/src/config.ts
  35. +13 −2 packages/plugins/other/hasura-allow-list/src/index.ts
  36. +44 −0 packages/plugins/other/hasura-allow-list/tests/hasura-allow-list.spec.ts
  37. +1 −1 packages/plugins/typescript/apollo-client-helpers/package.json
  38. +9 −0 packages/plugins/typescript/generic-sdk/CHANGELOG.md
  39. +1 −1 packages/plugins/typescript/generic-sdk/package.json
  40. +15 −5 packages/plugins/typescript/generic-sdk/src/visitor.ts
  41. +8 −8 packages/plugins/typescript/generic-sdk/tests/__snapshots__/generic-sdk.spec.ts.snap
  42. +2 −2 packages/plugins/typescript/graphql-apollo/package.json
  43. +39 −0 packages/plugins/typescript/graphql-request/CHANGELOG.md
  44. +2 −2 packages/plugins/typescript/graphql-request/package.json
  45. +4 −2 packages/plugins/typescript/graphql-request/src/index.ts
  46. +15 −10 packages/plugins/typescript/graphql-request/src/visitor.ts
  47. +355 −75 packages/plugins/typescript/graphql-request/tests/__snapshots__/graphql-request.spec.ts.snap
  48. +34 −4 packages/plugins/typescript/graphql-request/tests/graphql-request.spec.ts
  49. +1 −1 packages/plugins/typescript/jit-sdk/package.json
  50. +1 −1 packages/plugins/typescript/mongodb/package.json
  51. +18 −0 packages/plugins/typescript/msw/CHANGELOG.md
  52. +3 −2 packages/plugins/typescript/msw/package.json
  53. +20 −11 packages/plugins/typescript/msw/src/visitor.ts
  54. +133 −83 packages/plugins/typescript/msw/tests/__snapshots__/msw.spec.ts.snap
  55. +8 −6 packages/plugins/typescript/msw/tests/msw.spec.ts
  56. +10 −0 packages/plugins/typescript/nest/CHANGELOG.md
  57. +1 −0 packages/plugins/typescript/nest/jest.config.js
  58. +59 −0 packages/plugins/typescript/nest/package.json
  59. +34 −0 packages/plugins/typescript/nest/src/config.ts
  60. +9 −0 packages/plugins/typescript/nest/src/constants.ts
  61. +41 −0 packages/plugins/typescript/nest/src/index.ts
  62. +21 −0 packages/plugins/typescript/nest/src/types.ts
  63. +62 −0 packages/plugins/typescript/nest/src/utils.ts
  64. +450 −0 packages/plugins/typescript/nest/src/visitor.ts
  65. +840 −0 packages/plugins/typescript/nest/tests/nest.spec.ts
  66. +22 −0 packages/plugins/typescript/react-apollo/CHANGELOG.md
  67. +1 −1 packages/plugins/typescript/react-apollo/package.json
  68. +40 −2 packages/plugins/typescript/react-apollo/src/config.ts
  69. +82 −3 packages/plugins/typescript/react-apollo/src/visitor.ts
  70. +20 −0 packages/plugins/typescript/react-apollo/tests/__snapshots__/react-apollo.spec.ts.snap
  71. +142 −2 packages/plugins/typescript/react-apollo/tests/react-apollo.spec.ts
  72. +24 −0 packages/plugins/typescript/react-query/CHANGELOG.md
  73. +1 −1 packages/plugins/typescript/react-query/package.json
  74. +51 −35 packages/plugins/typescript/react-query/src/config.ts
  75. +41 −100 packages/plugins/typescript/react-query/src/fetcher-custom-mapper.ts
  76. +37 −109 packages/plugins/typescript/react-query/src/fetcher-fetch-hardcoded.ts
  77. +43 −100 packages/plugins/typescript/react-query/src/fetcher-fetch.ts
  78. +91 −104 packages/plugins/typescript/react-query/src/fetcher-graphql-request.ts
  79. +319 −34 packages/plugins/typescript/react-query/src/fetcher.ts
  80. +9 −1 packages/plugins/typescript/react-query/src/index.ts
  81. +0 −68 packages/plugins/typescript/react-query/src/variables-generator.ts
  82. +59 −127 packages/plugins/typescript/react-query/src/visitor.ts
  83. +883 −107 packages/plugins/typescript/react-query/tests/__snapshots__/react-query.spec.ts.snap
  84. +93 −405 packages/plugins/typescript/react-query/tests/react-query.spec.ts
  85. +20 −0 packages/plugins/typescript/rtk-query/CHANGELOG.md
  86. +4 −4 packages/plugins/typescript/rtk-query/package.json
  87. +9 −0 packages/plugins/typescript/solid-query/CHANGELOG.md
  88. +1 −0 packages/plugins/typescript/solid-query/jest.config.js
  89. +56 −0 packages/plugins/typescript/solid-query/package.json
  90. +131 −0 packages/plugins/typescript/solid-query/src/config.ts
  91. +115 −0 packages/plugins/typescript/solid-query/src/fetcher-custom-mapper.ts
  92. +97 −0 packages/plugins/typescript/solid-query/src/fetcher-fetch-hardcoded.ts
  93. +92 −0 packages/plugins/typescript/solid-query/src/fetcher-fetch.ts
  94. +145 −0 packages/plugins/typescript/solid-query/src/fetcher-graphql-request.ts
  95. +286 −0 packages/plugins/typescript/solid-query/src/fetcher.ts
  96. +64 −0 packages/plugins/typescript/solid-query/src/index.ts
  97. +208 −0 packages/plugins/typescript/solid-query/src/visitor.ts
  98. +1,264 −0 packages/plugins/typescript/solid-query/tests/__snapshots__/solid-query.spec.ts.snap
  99. +1,022 −0 packages/plugins/typescript/solid-query/tests/solid-query.spec.ts
  100. +9 −0 packages/plugins/typescript/urql-graphcache/CHANGELOG.md
  101. +1 −1 packages/plugins/typescript/urql-graphcache/package.json
  102. +3 −1 packages/plugins/typescript/urql-graphcache/src/config.ts
  103. +6 −2 packages/plugins/typescript/urql-graphcache/src/index.ts
  104. +12 −12 packages/plugins/typescript/urql-graphcache/tests/__snapshots__/urql.spec.ts.snap
  105. +1 −1 packages/plugins/typescript/urql-graphcache/tests/urql.spec.ts
  106. +17 −0 packages/plugins/typescript/vue-apollo/CHANGELOG.md
  107. +1 −1 packages/plugins/typescript/vue-apollo/package.json
  108. +23 −0 packages/plugins/typescript/vue-apollo/src/config.ts
  109. +13 −9 packages/plugins/typescript/vue-apollo/src/visitor.ts
  110. +52 −43 packages/plugins/typescript/vue-apollo/tests/vue-apollo.spec.ts
  111. +1 −1 packages/presets/near-operation-file/package.json
  112. +10 −1 renovate.json
  113. +2 −1 tsconfig.json
  114. +1,050 −1,000 yarn.lock
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ jobs:
- name: Install Dependencies
run: yarn
- name: Cache Jest
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: .cache/jest
key: ${{runner.os}}-${{matrix.node_version}}-${{matrix.graphql_version}}-jest-${{hashFiles('yarn.lock')}}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -19,5 +19,8 @@
},
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -61,6 +61,8 @@ plugins:
`@graphql-codegen/java-resolvers`
- [![npm version](https://badge.fury.io/js/%40graphql-codegen%2Fjava-apollo-android.svg)](https://badge.fury.io/js/%40graphql-codegen%2Fjava-apollo-android) -
`@graphql-codegen/java-apollo-android`
- [![npm version](https://badge.fury.io/js/%40graphql-codegen%2Ftypescript-nest.svg)](https://badge.fury.io/js/%40graphql-codegen%2Ftypescript-nest) -
`@graphql-codegen/typescript-nest`

### Getting started with codegen

10 changes: 9 additions & 1 deletion dev-test/codegen.ts
Original file line number Diff line number Diff line change
@@ -44,7 +44,15 @@ const config: CodegenConfig = {
'./dev-test/githunt/types.reactApollo.hooks.tsx': {
schema: './dev-test/githunt/schema.json',
documents: './dev-test/githunt/**/*.graphql',
plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
plugins: [
'typescript',
'typescript-operations',
{
'typescript-react-apollo': {
withFragmentHooks: true,
},
},
],
},
'./dev-test/githunt/types.react-query.ts': {
schema: './dev-test/githunt/schema.json',
56 changes: 38 additions & 18 deletions dev-test/githunt/types.react-query.ts
Original file line number Diff line number Diff line change
@@ -460,12 +460,13 @@ export const CommentDocument = `
}
}
${CommentsPageCommentFragmentDoc}`;

export const useCommentQuery = <TData = CommentQuery, TError = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables: CommentQueryVariables,
options?: UseQueryOptions<CommentQuery, TError, TData>,
) =>
useQuery<CommentQuery, TError, TData>(
) => {
return useQuery<CommentQuery, TError, TData>(
['Comment', variables],
fetcher<CommentQuery, CommentQueryVariables>(
dataSource.endpoint,
@@ -475,12 +476,14 @@ export const useCommentQuery = <TData = CommentQuery, TError = unknown>(
),
options,
);
};

export const useInfiniteCommentQuery = <TData = CommentQuery, TError = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables: CommentQueryVariables,
options?: UseInfiniteQueryOptions<CommentQuery, TError, TData>,
) =>
useInfiniteQuery<CommentQuery, TError, TData>(
) => {
return useInfiniteQuery<CommentQuery, TError, TData>(
['Comment.infinite', variables],
metaData =>
fetcher<CommentQuery, CommentQueryVariables>(
@@ -491,6 +494,7 @@ export const useInfiniteCommentQuery = <TData = CommentQuery, TError = unknown>(
)(),
options,
);
};

export const CurrentUserForProfileDocument = `
query CurrentUserForProfile {
@@ -500,12 +504,13 @@ export const CurrentUserForProfileDocument = `
}
}
`;

export const useCurrentUserForProfileQuery = <TData = CurrentUserForProfileQuery, TError = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables?: CurrentUserForProfileQueryVariables,
options?: UseQueryOptions<CurrentUserForProfileQuery, TError, TData>,
) =>
useQuery<CurrentUserForProfileQuery, TError, TData>(
) => {
return useQuery<CurrentUserForProfileQuery, TError, TData>(
variables === undefined ? ['CurrentUserForProfile'] : ['CurrentUserForProfile', variables],
fetcher<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
dataSource.endpoint,
@@ -515,15 +520,17 @@ export const useCurrentUserForProfileQuery = <TData = CurrentUserForProfileQuery
),
options,
);
};

export const useInfiniteCurrentUserForProfileQuery = <
TData = CurrentUserForProfileQuery,
TError = unknown,
>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables?: CurrentUserForProfileQueryVariables,
options?: UseInfiniteQueryOptions<CurrentUserForProfileQuery, TError, TData>,
) =>
useInfiniteQuery<CurrentUserForProfileQuery, TError, TData>(
) => {
return useInfiniteQuery<CurrentUserForProfileQuery, TError, TData>(
variables === undefined
? ['CurrentUserForProfile.infinite']
: ['CurrentUserForProfile.infinite', variables],
@@ -536,6 +543,7 @@ export const useInfiniteCurrentUserForProfileQuery = <
)(),
options,
);
};

export const FeedDocument = `
query Feed($type: FeedType!, $offset: Int, $limit: Int) {
@@ -547,12 +555,13 @@ export const FeedDocument = `
}
}
${FeedEntryFragmentDoc}`;

export const useFeedQuery = <TData = FeedQuery, TError = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables: FeedQueryVariables,
options?: UseQueryOptions<FeedQuery, TError, TData>,
) =>
useQuery<FeedQuery, TError, TData>(
) => {
return useQuery<FeedQuery, TError, TData>(
['Feed', variables],
fetcher<FeedQuery, FeedQueryVariables>(
dataSource.endpoint,
@@ -562,12 +571,14 @@ export const useFeedQuery = <TData = FeedQuery, TError = unknown>(
),
options,
);
};

export const useInfiniteFeedQuery = <TData = FeedQuery, TError = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
variables: FeedQueryVariables,
options?: UseInfiniteQueryOptions<FeedQuery, TError, TData>,
) =>
useInfiniteQuery<FeedQuery, TError, TData>(
) => {
return useInfiniteQuery<FeedQuery, TError, TData>(
['Feed.infinite', variables],
metaData =>
fetcher<FeedQuery, FeedQueryVariables>(
@@ -578,6 +589,7 @@ export const useInfiniteFeedQuery = <TData = FeedQuery, TError = unknown>(
)(),
options,
);
};

export const SubmitRepositoryDocument = `
mutation submitRepository($repoFullName: String!) {
@@ -586,6 +598,7 @@ export const SubmitRepositoryDocument = `
}
}
`;

export const useSubmitRepositoryMutation = <TError = unknown, TContext = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
options?: UseMutationOptions<
@@ -594,8 +607,8 @@ export const useSubmitRepositoryMutation = <TError = unknown, TContext = unknown
SubmitRepositoryMutationVariables,
TContext
>,
) =>
useMutation<SubmitRepositoryMutation, TError, SubmitRepositoryMutationVariables, TContext>(
) => {
return useMutation<SubmitRepositoryMutation, TError, SubmitRepositoryMutationVariables, TContext>(
['submitRepository'],
(variables?: SubmitRepositoryMutationVariables) =>
fetcher<SubmitRepositoryMutation, SubmitRepositoryMutationVariables>(
@@ -606,13 +619,16 @@ export const useSubmitRepositoryMutation = <TError = unknown, TContext = unknown
)(),
options,
);
};

export const SubmitCommentDocument = `
mutation submitComment($repoFullName: String!, $commentContent: String!) {
submitComment(repoFullName: $repoFullName, commentContent: $commentContent) {
...CommentsPageComment
}
}
${CommentsPageCommentFragmentDoc}`;

export const useSubmitCommentMutation = <TError = unknown, TContext = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
options?: UseMutationOptions<
@@ -621,8 +637,8 @@ export const useSubmitCommentMutation = <TError = unknown, TContext = unknown>(
SubmitCommentMutationVariables,
TContext
>,
) =>
useMutation<SubmitCommentMutation, TError, SubmitCommentMutationVariables, TContext>(
) => {
return useMutation<SubmitCommentMutation, TError, SubmitCommentMutationVariables, TContext>(
['submitComment'],
(variables?: SubmitCommentMutationVariables) =>
fetcher<SubmitCommentMutation, SubmitCommentMutationVariables>(
@@ -633,6 +649,8 @@ export const useSubmitCommentMutation = <TError = unknown, TContext = unknown>(
)(),
options,
);
};

export const VoteDocument = `
mutation vote($repoFullName: String!, $type: VoteType!) {
vote(repoFullName: $repoFullName, type: $type) {
@@ -644,11 +662,12 @@ export const VoteDocument = `
}
}
`;

export const useVoteMutation = <TError = unknown, TContext = unknown>(
dataSource: { endpoint: string; fetchParams?: RequestInit },
options?: UseMutationOptions<VoteMutation, TError, VoteMutationVariables, TContext>,
) =>
useMutation<VoteMutation, TError, VoteMutationVariables, TContext>(
) => {
return useMutation<VoteMutation, TError, VoteMutationVariables, TContext>(
['vote'],
(variables?: VoteMutationVariables) =>
fetcher<VoteMutation, VoteMutationVariables>(
@@ -659,3 +678,4 @@ export const useVoteMutation = <TError = unknown, TContext = unknown>(
)(),
options,
);
};
32 changes: 32 additions & 0 deletions dev-test/githunt/types.reactApollo.customSuffix.tsx
Original file line number Diff line number Diff line change
@@ -498,8 +498,18 @@ export function useCommentLazyQuery(
options,
);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQueryMyOperation, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQueryMyOperation, CommentQueryVariables>(
CommentDocument,
options,
);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
export type CommentLazyQueryHookResult = ReturnType<typeof useCommentLazyQuery>;
export type CommentSuspenseQueryHookResult = ReturnType<typeof useCommentSuspenseQuery>;
export type CommentQueryResult = Apollo.QueryResult<CommentQueryMyOperation, CommentQueryVariables>;
export const CurrentUserForProfileDocument = gql`
query CurrentUserForProfile {
@@ -549,10 +559,25 @@ export function useCurrentUserForProfileLazyQuery(
CurrentUserForProfileQueryVariables
>(CurrentUserForProfileDocument, options);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQueryMyOperation,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<
CurrentUserForProfileQueryMyOperation,
CurrentUserForProfileQueryVariables
>(CurrentUserForProfileDocument, options);
}
export type CurrentUserForProfileQueryHookResult = ReturnType<typeof useCurrentUserForProfileQuery>;
export type CurrentUserForProfileLazyQueryHookResult = ReturnType<
typeof useCurrentUserForProfileLazyQuery
>;
export type CurrentUserForProfileSuspenseQueryHookResult = ReturnType<
typeof useCurrentUserForProfileSuspenseQuery
>;
export type CurrentUserForProfileQueryResult = Apollo.QueryResult<
CurrentUserForProfileQueryMyOperation,
CurrentUserForProfileQueryVariables
@@ -599,8 +624,15 @@ export function useFeedLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<FeedQueryMyOperation, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQueryMyOperation, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQueryMyOperation, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
export type FeedLazyQueryHookResult = ReturnType<typeof useFeedLazyQuery>;
export type FeedSuspenseQueryHookResult = ReturnType<typeof useFeedSuspenseQuery>;
export type FeedQueryResult = Apollo.QueryResult<FeedQueryMyOperation, FeedQueryVariables>;
export const SubmitRepositoryDocument = gql`
mutation submitRepository($repoFullName: String!) {
75 changes: 75 additions & 0 deletions dev-test/githunt/types.reactApollo.hooks.tsx
Original file line number Diff line number Diff line change
@@ -389,6 +389,52 @@ export const FeedEntryFragmentDoc = gql`
${VoteButtonsFragmentDoc}
${RepoInfoFragmentDoc}
`;
export function useCommentsPageCommentFragment<F = { id: string }>(identifiers: F) {
return Apollo.useFragment<CommentsPageCommentFragment>({
fragment: CommentsPageCommentFragmentDoc,
fragmentName: 'CommentsPageComment',
from: {
__typename: 'Comment',
...identifiers,
},
});
}
export type CommentsPageCommentFragmentHookResult = ReturnType<
typeof useCommentsPageCommentFragment
>;
export function useFeedEntryFragment<F = { id: string }>(identifiers: F) {
return Apollo.useFragment<FeedEntryFragment>({
fragment: FeedEntryFragmentDoc,
fragmentName: 'FeedEntry',
from: {
__typename: 'Entry',
...identifiers,
},
});
}
export type FeedEntryFragmentHookResult = ReturnType<typeof useFeedEntryFragment>;
export function useRepoInfoFragment<F = { id: string }>(identifiers: F) {
return Apollo.useFragment<RepoInfoFragment>({
fragment: RepoInfoFragmentDoc,
fragmentName: 'RepoInfo',
from: {
__typename: 'Entry',
...identifiers,
},
});
}
export type RepoInfoFragmentHookResult = ReturnType<typeof useRepoInfoFragment>;
export function useVoteButtonsFragment<F = { id: string }>(identifiers: F) {
return Apollo.useFragment<VoteButtonsFragment>({
fragment: VoteButtonsFragmentDoc,
fragmentName: 'VoteButtons',
from: {
__typename: 'Entry',
...identifiers,
},
});
}
export type VoteButtonsFragmentHookResult = ReturnType<typeof useVoteButtonsFragment>;
export const OnCommentAddedDocument = gql`
subscription onCommentAdded($repoFullName: String!) {
commentAdded(repoFullName: $repoFullName) {
@@ -495,8 +541,15 @@ export function useCommentLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
export type CommentLazyQueryHookResult = ReturnType<typeof useCommentLazyQuery>;
export type CommentSuspenseQueryHookResult = ReturnType<typeof useCommentSuspenseQuery>;
export type CommentQueryResult = Apollo.QueryResult<CommentQuery, CommentQueryVariables>;
export const CurrentUserForProfileDocument = gql`
query CurrentUserForProfile {
@@ -546,10 +599,25 @@ export function useCurrentUserForProfileLazyQuery(
options,
);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
CurrentUserForProfileDocument,
options,
);
}
export type CurrentUserForProfileQueryHookResult = ReturnType<typeof useCurrentUserForProfileQuery>;
export type CurrentUserForProfileLazyQueryHookResult = ReturnType<
typeof useCurrentUserForProfileLazyQuery
>;
export type CurrentUserForProfileSuspenseQueryHookResult = ReturnType<
typeof useCurrentUserForProfileSuspenseQuery
>;
export type CurrentUserForProfileQueryResult = Apollo.QueryResult<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
@@ -594,8 +662,15 @@ export function useFeedLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
export type FeedLazyQueryHookResult = ReturnType<typeof useFeedLazyQuery>;
export type FeedSuspenseQueryHookResult = ReturnType<typeof useFeedSuspenseQuery>;
export type FeedQueryResult = Apollo.QueryResult<FeedQuery, FeedQueryVariables>;
export const SubmitRepositoryDocument = gql`
mutation submitRepository($repoFullName: String!) {
29 changes: 29 additions & 0 deletions dev-test/githunt/types.reactApollo.preResolveTypes.tsx
Original file line number Diff line number Diff line change
@@ -495,8 +495,15 @@ export function useCommentLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
export type CommentLazyQueryHookResult = ReturnType<typeof useCommentLazyQuery>;
export type CommentSuspenseQueryHookResult = ReturnType<typeof useCommentSuspenseQuery>;
export type CommentQueryResult = Apollo.QueryResult<CommentQuery, CommentQueryVariables>;
export const CurrentUserForProfileDocument = gql`
query CurrentUserForProfile {
@@ -546,10 +553,25 @@ export function useCurrentUserForProfileLazyQuery(
options,
);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
CurrentUserForProfileDocument,
options,
);
}
export type CurrentUserForProfileQueryHookResult = ReturnType<typeof useCurrentUserForProfileQuery>;
export type CurrentUserForProfileLazyQueryHookResult = ReturnType<
typeof useCurrentUserForProfileLazyQuery
>;
export type CurrentUserForProfileSuspenseQueryHookResult = ReturnType<
typeof useCurrentUserForProfileSuspenseQuery
>;
export type CurrentUserForProfileQueryResult = Apollo.QueryResult<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
@@ -594,8 +616,15 @@ export function useFeedLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
export type FeedLazyQueryHookResult = ReturnType<typeof useFeedLazyQuery>;
export type FeedSuspenseQueryHookResult = ReturnType<typeof useFeedSuspenseQuery>;
export type FeedQueryResult = Apollo.QueryResult<FeedQuery, FeedQueryVariables>;
export const SubmitRepositoryDocument = gql`
mutation submitRepository($repoFullName: String!) {
29 changes: 29 additions & 0 deletions dev-test/githunt/types.reactApollo.tsx
Original file line number Diff line number Diff line change
@@ -495,8 +495,15 @@ export function useCommentLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export function useCommentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CommentQuery, CommentQueryVariables>(CommentDocument, options);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
export type CommentLazyQueryHookResult = ReturnType<typeof useCommentLazyQuery>;
export type CommentSuspenseQueryHookResult = ReturnType<typeof useCommentSuspenseQuery>;
export type CommentQueryResult = Apollo.QueryResult<CommentQuery, CommentQueryVariables>;
export const CurrentUserForProfileDocument = gql`
query CurrentUserForProfile {
@@ -546,10 +553,25 @@ export function useCurrentUserForProfileLazyQuery(
options,
);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<CurrentUserForProfileQuery, CurrentUserForProfileQueryVariables>(
CurrentUserForProfileDocument,
options,
);
}
export type CurrentUserForProfileQueryHookResult = ReturnType<typeof useCurrentUserForProfileQuery>;
export type CurrentUserForProfileLazyQueryHookResult = ReturnType<
typeof useCurrentUserForProfileLazyQuery
>;
export type CurrentUserForProfileSuspenseQueryHookResult = ReturnType<
typeof useCurrentUserForProfileSuspenseQuery
>;
export type CurrentUserForProfileQueryResult = Apollo.QueryResult<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
@@ -594,8 +616,15 @@ export function useFeedLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
export type FeedLazyQueryHookResult = ReturnType<typeof useFeedLazyQuery>;
export type FeedSuspenseQueryHookResult = ReturnType<typeof useFeedSuspenseQuery>;
export type FeedQueryResult = Apollo.QueryResult<FeedQuery, FeedQueryVariables>;
export const SubmitRepositoryDocument = gql`
mutation submitRepository($repoFullName: String!) {
32 changes: 32 additions & 0 deletions dev-test/githunt/types.reactApollo.v2.tsx
Original file line number Diff line number Diff line change
@@ -499,8 +499,18 @@ export function useCommentLazyQuery(
options,
);
}
export function useCommentSuspenseQuery(
baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<CommentQuery, CommentQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return ApolloReactHooks.useSuspenseQuery<CommentQuery, CommentQueryVariables>(
CommentDocument,
options,
);
}
export type CommentQueryHookResult = ReturnType<typeof useCommentQuery>;
export type CommentLazyQueryHookResult = ReturnType<typeof useCommentLazyQuery>;
export type CommentSuspenseQueryHookResult = ReturnType<typeof useCommentSuspenseQuery>;
export type CommentQueryResult = ApolloReactCommon.QueryResult<CommentQuery, CommentQueryVariables>;
export const CurrentUserForProfileDocument = gql`
query CurrentUserForProfile {
@@ -550,10 +560,25 @@ export function useCurrentUserForProfileLazyQuery(
CurrentUserForProfileQueryVariables
>(CurrentUserForProfileDocument, options);
}
export function useCurrentUserForProfileSuspenseQuery(
baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return ApolloReactHooks.useSuspenseQuery<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
>(CurrentUserForProfileDocument, options);
}
export type CurrentUserForProfileQueryHookResult = ReturnType<typeof useCurrentUserForProfileQuery>;
export type CurrentUserForProfileLazyQueryHookResult = ReturnType<
typeof useCurrentUserForProfileLazyQuery
>;
export type CurrentUserForProfileSuspenseQueryHookResult = ReturnType<
typeof useCurrentUserForProfileSuspenseQuery
>;
export type CurrentUserForProfileQueryResult = ApolloReactCommon.QueryResult<
CurrentUserForProfileQuery,
CurrentUserForProfileQueryVariables
@@ -600,8 +625,15 @@ export function useFeedLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return ApolloReactHooks.useLazyQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export function useFeedSuspenseQuery(
baseOptions?: ApolloReactHooks.SuspenseQueryHookOptions<FeedQuery, FeedQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return ApolloReactHooks.useSuspenseQuery<FeedQuery, FeedQueryVariables>(FeedDocument, options);
}
export type FeedQueryHookResult = ReturnType<typeof useFeedQuery>;
export type FeedLazyQueryHookResult = ReturnType<typeof useFeedLazyQuery>;
export type FeedSuspenseQueryHookResult = ReturnType<typeof useFeedSuspenseQuery>;
export type FeedQueryResult = ApolloReactCommon.QueryResult<FeedQuery, FeedQueryVariables>;
export const SubmitRepositoryDocument = gql`
mutation submitRepository($repoFullName: String!) {
4 changes: 2 additions & 2 deletions dev-test/githunt/types.urql.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IntrospectionQuery } from 'graphql';
import gql from 'graphql-tag';
import * as Urql from 'urql';
import { offlineExchange } from '@urql/exchange-graphcache';
import { cacheExchange } from '@urql/exchange-graphcache';
import {
OptimisticMutationResolver as GraphCacheOptimisticMutationResolver,
Resolver as GraphCacheResolver,
@@ -1293,7 +1293,7 @@ export type GraphCacheUpdaters = {
};
};

export type GraphCacheConfig = Parameters<typeof offlineExchange>[0] & {
export type GraphCacheConfig = Parameters<typeof cacheExchange>[0] & {
updates?: GraphCacheUpdaters;
keys?: GraphCacheKeysConfig;
optimistic?: GraphCacheOptimisticUpdaters;
4 changes: 2 additions & 2 deletions dev-test/githunt/types.vueApollo.ts
Original file line number Diff line number Diff line change
@@ -521,7 +521,7 @@ export function useCommentQuery(
);
}
export function useCommentLazyQuery(
variables:
variables?:
| CommentQueryVariables
| VueCompositionApi.Ref<CommentQueryVariables>
| ReactiveFunction<CommentQueryVariables>,
@@ -664,7 +664,7 @@ export function useFeedQuery(
);
}
export function useFeedLazyQuery(
variables:
variables?:
| FeedQueryVariables
| VueCompositionApi.Ref<FeedQueryVariables>
| ReactiveFunction<FeedQueryVariables>,
15 changes: 15 additions & 0 deletions dev-test/star-wars/__generated__/HeroAndFriendsNames.tsx
10 changes: 10 additions & 0 deletions dev-test/star-wars/__generated__/HeroAppearsIn.tsx
10 changes: 10 additions & 0 deletions dev-test/star-wars/__generated__/HeroDetails.tsx
15 changes: 15 additions & 0 deletions dev-test/star-wars/__generated__/HeroDetailsWithFragment.tsx
7 changes: 7 additions & 0 deletions dev-test/star-wars/__generated__/HeroName.tsx
30 changes: 30 additions & 0 deletions dev-test/star-wars/__generated__/HeroNameConditional.tsx
15 changes: 15 additions & 0 deletions dev-test/star-wars/__generated__/HeroParentTypeDependentField.tsx
15 changes: 15 additions & 0 deletions dev-test/star-wars/__generated__/HeroTypeDependentAliasedField.tsx
15 changes: 15 additions & 0 deletions dev-test/star-wars/__generated__/HumanWithNullWeight.tsx
10 changes: 10 additions & 0 deletions dev-test/star-wars/__generated__/TwoHeroes.tsx
142 changes: 142 additions & 0 deletions dev-test/star-wars/types.refetchFn.tsx
Original file line number Diff line number Diff line change
@@ -362,10 +362,25 @@ export function useHeroAndFriendsNamesLazyQuery(
options,
);
}
export function useHeroAndFriendsNamesSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
HeroAndFriendsNamesQuery,
HeroAndFriendsNamesQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<HeroAndFriendsNamesQuery, HeroAndFriendsNamesQueryVariables>(
HeroAndFriendsNamesDocument,
options,
);
}
export type HeroAndFriendsNamesQueryHookResult = ReturnType<typeof useHeroAndFriendsNamesQuery>;
export type HeroAndFriendsNamesLazyQueryHookResult = ReturnType<
typeof useHeroAndFriendsNamesLazyQuery
>;
export type HeroAndFriendsNamesSuspenseQueryHookResult = ReturnType<
typeof useHeroAndFriendsNamesSuspenseQuery
>;
export type HeroAndFriendsNamesQueryResult = Apollo.QueryResult<
HeroAndFriendsNamesQuery,
HeroAndFriendsNamesQueryVariables
@@ -415,8 +430,18 @@ export function useHeroAppearsInLazyQuery(
options,
);
}
export function useHeroAppearsInSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<HeroAppearsInQuery, HeroAppearsInQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<HeroAppearsInQuery, HeroAppearsInQueryVariables>(
HeroAppearsInDocument,
options,
);
}
export type HeroAppearsInQueryHookResult = ReturnType<typeof useHeroAppearsInQuery>;
export type HeroAppearsInLazyQueryHookResult = ReturnType<typeof useHeroAppearsInLazyQuery>;
export type HeroAppearsInSuspenseQueryHookResult = ReturnType<typeof useHeroAppearsInSuspenseQuery>;
export type HeroAppearsInQueryResult = Apollo.QueryResult<
HeroAppearsInQuery,
HeroAppearsInQueryVariables
@@ -469,8 +494,18 @@ export function useHeroDetailsLazyQuery(
options,
);
}
export function useHeroDetailsSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<HeroDetailsQuery, HeroDetailsQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<HeroDetailsQuery, HeroDetailsQueryVariables>(
HeroDetailsDocument,
options,
);
}
export type HeroDetailsQueryHookResult = ReturnType<typeof useHeroDetailsQuery>;
export type HeroDetailsLazyQueryHookResult = ReturnType<typeof useHeroDetailsLazyQuery>;
export type HeroDetailsSuspenseQueryHookResult = ReturnType<typeof useHeroDetailsSuspenseQuery>;
export type HeroDetailsQueryResult = Apollo.QueryResult<
HeroDetailsQuery,
HeroDetailsQueryVariables
@@ -527,12 +562,27 @@ export function useHeroDetailsWithFragmentLazyQuery(
options,
);
}
export function useHeroDetailsWithFragmentSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
HeroDetailsWithFragmentQuery,
HeroDetailsWithFragmentQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<
HeroDetailsWithFragmentQuery,
HeroDetailsWithFragmentQueryVariables
>(HeroDetailsWithFragmentDocument, options);
}
export type HeroDetailsWithFragmentQueryHookResult = ReturnType<
typeof useHeroDetailsWithFragmentQuery
>;
export type HeroDetailsWithFragmentLazyQueryHookResult = ReturnType<
typeof useHeroDetailsWithFragmentLazyQuery
>;
export type HeroDetailsWithFragmentSuspenseQueryHookResult = ReturnType<
typeof useHeroDetailsWithFragmentSuspenseQuery
>;
export type HeroDetailsWithFragmentQueryResult = Apollo.QueryResult<
HeroDetailsWithFragmentQuery,
HeroDetailsWithFragmentQueryVariables
@@ -578,8 +628,15 @@ export function useHeroNameLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<HeroNameQuery, HeroNameQueryVariables>(HeroNameDocument, options);
}
export function useHeroNameSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<HeroNameQuery, HeroNameQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<HeroNameQuery, HeroNameQueryVariables>(HeroNameDocument, options);
}
export type HeroNameQueryHookResult = ReturnType<typeof useHeroNameQuery>;
export type HeroNameLazyQueryHookResult = ReturnType<typeof useHeroNameLazyQuery>;
export type HeroNameSuspenseQueryHookResult = ReturnType<typeof useHeroNameSuspenseQuery>;
export type HeroNameQueryResult = Apollo.QueryResult<HeroNameQuery, HeroNameQueryVariables>;
export function refetchHeroNameQuery(variables?: HeroNameQueryVariables) {
return { query: HeroNameDocument, variables: variables };
@@ -633,12 +690,27 @@ export function useHeroNameConditionalInclusionLazyQuery(
HeroNameConditionalInclusionQueryVariables
>(HeroNameConditionalInclusionDocument, options);
}
export function useHeroNameConditionalInclusionSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
HeroNameConditionalInclusionQuery,
HeroNameConditionalInclusionQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<
HeroNameConditionalInclusionQuery,
HeroNameConditionalInclusionQueryVariables
>(HeroNameConditionalInclusionDocument, options);
}
export type HeroNameConditionalInclusionQueryHookResult = ReturnType<
typeof useHeroNameConditionalInclusionQuery
>;
export type HeroNameConditionalInclusionLazyQueryHookResult = ReturnType<
typeof useHeroNameConditionalInclusionLazyQuery
>;
export type HeroNameConditionalInclusionSuspenseQueryHookResult = ReturnType<
typeof useHeroNameConditionalInclusionSuspenseQuery
>;
export type HeroNameConditionalInclusionQueryResult = Apollo.QueryResult<
HeroNameConditionalInclusionQuery,
HeroNameConditionalInclusionQueryVariables
@@ -697,12 +769,27 @@ export function useHeroNameConditionalExclusionLazyQuery(
HeroNameConditionalExclusionQueryVariables
>(HeroNameConditionalExclusionDocument, options);
}
export function useHeroNameConditionalExclusionSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
HeroNameConditionalExclusionQuery,
HeroNameConditionalExclusionQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<
HeroNameConditionalExclusionQuery,
HeroNameConditionalExclusionQueryVariables
>(HeroNameConditionalExclusionDocument, options);
}
export type HeroNameConditionalExclusionQueryHookResult = ReturnType<
typeof useHeroNameConditionalExclusionQuery
>;
export type HeroNameConditionalExclusionLazyQueryHookResult = ReturnType<
typeof useHeroNameConditionalExclusionLazyQuery
>;
export type HeroNameConditionalExclusionSuspenseQueryHookResult = ReturnType<
typeof useHeroNameConditionalExclusionSuspenseQuery
>;
export type HeroNameConditionalExclusionQueryResult = Apollo.QueryResult<
HeroNameConditionalExclusionQuery,
HeroNameConditionalExclusionQueryVariables
@@ -776,12 +863,27 @@ export function useHeroParentTypeDependentFieldLazyQuery(
HeroParentTypeDependentFieldQueryVariables
>(HeroParentTypeDependentFieldDocument, options);
}
export function useHeroParentTypeDependentFieldSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
HeroParentTypeDependentFieldQuery,
HeroParentTypeDependentFieldQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<
HeroParentTypeDependentFieldQuery,
HeroParentTypeDependentFieldQueryVariables
>(HeroParentTypeDependentFieldDocument, options);
}
export type HeroParentTypeDependentFieldQueryHookResult = ReturnType<
typeof useHeroParentTypeDependentFieldQuery
>;
export type HeroParentTypeDependentFieldLazyQueryHookResult = ReturnType<
typeof useHeroParentTypeDependentFieldLazyQuery
>;
export type HeroParentTypeDependentFieldSuspenseQueryHookResult = ReturnType<
typeof useHeroParentTypeDependentFieldSuspenseQuery
>;
export type HeroParentTypeDependentFieldQueryResult = Apollo.QueryResult<
HeroParentTypeDependentFieldQuery,
HeroParentTypeDependentFieldQueryVariables
@@ -844,12 +946,27 @@ export function useHeroTypeDependentAliasedFieldLazyQuery(
HeroTypeDependentAliasedFieldQueryVariables
>(HeroTypeDependentAliasedFieldDocument, options);
}
export function useHeroTypeDependentAliasedFieldSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
HeroTypeDependentAliasedFieldQuery,
HeroTypeDependentAliasedFieldQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<
HeroTypeDependentAliasedFieldQuery,
HeroTypeDependentAliasedFieldQueryVariables
>(HeroTypeDependentAliasedFieldDocument, options);
}
export type HeroTypeDependentAliasedFieldQueryHookResult = ReturnType<
typeof useHeroTypeDependentAliasedFieldQuery
>;
export type HeroTypeDependentAliasedFieldLazyQueryHookResult = ReturnType<
typeof useHeroTypeDependentAliasedFieldLazyQuery
>;
export type HeroTypeDependentAliasedFieldSuspenseQueryHookResult = ReturnType<
typeof useHeroTypeDependentAliasedFieldSuspenseQuery
>;
export type HeroTypeDependentAliasedFieldQueryResult = Apollo.QueryResult<
HeroTypeDependentAliasedFieldQuery,
HeroTypeDependentAliasedFieldQueryVariables
@@ -907,10 +1024,25 @@ export function useHumanWithNullHeightLazyQuery(
options,
);
}
export function useHumanWithNullHeightSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<
HumanWithNullHeightQuery,
HumanWithNullHeightQueryVariables
>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<HumanWithNullHeightQuery, HumanWithNullHeightQueryVariables>(
HumanWithNullHeightDocument,
options,
);
}
export type HumanWithNullHeightQueryHookResult = ReturnType<typeof useHumanWithNullHeightQuery>;
export type HumanWithNullHeightLazyQueryHookResult = ReturnType<
typeof useHumanWithNullHeightLazyQuery
>;
export type HumanWithNullHeightSuspenseQueryHookResult = ReturnType<
typeof useHumanWithNullHeightSuspenseQuery
>;
export type HumanWithNullHeightQueryResult = Apollo.QueryResult<
HumanWithNullHeightQuery,
HumanWithNullHeightQueryVariables
@@ -956,8 +1088,18 @@ export function useTwoHeroesLazyQuery(
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useLazyQuery<TwoHeroesQuery, TwoHeroesQueryVariables>(TwoHeroesDocument, options);
}
export function useTwoHeroesSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<TwoHeroesQuery, TwoHeroesQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<TwoHeroesQuery, TwoHeroesQueryVariables>(
TwoHeroesDocument,
options,
);
}
export type TwoHeroesQueryHookResult = ReturnType<typeof useTwoHeroesQuery>;
export type TwoHeroesLazyQueryHookResult = ReturnType<typeof useTwoHeroesLazyQuery>;
export type TwoHeroesSuspenseQueryHookResult = ReturnType<typeof useTwoHeroesSuspenseQuery>;
export type TwoHeroesQueryResult = Apollo.QueryResult<TwoHeroesQuery, TwoHeroesQueryVariables>;
export function refetchTwoHeroesQuery(variables?: TwoHeroesQueryVariables) {
return { query: TwoHeroesDocument, variables: variables };
10 changes: 10 additions & 0 deletions dev-test/test-message/types.tsx
Original file line number Diff line number Diff line change
@@ -139,8 +139,18 @@ export function useGetMessagesLazyQuery(
options,
);
}
export function useGetMessagesSuspenseQuery(
baseOptions?: Apollo.SuspenseQueryHookOptions<GetMessagesQuery, GetMessagesQueryVariables>,
) {
const options = { ...defaultOptions, ...baseOptions };
return Apollo.useSuspenseQuery<GetMessagesQuery, GetMessagesQueryVariables>(
Operations.GetMessages,
options,
);
}
export type GetMessagesQueryHookResult = ReturnType<typeof useGetMessagesQuery>;
export type GetMessagesLazyQueryHookResult = ReturnType<typeof useGetMessagesLazyQuery>;
export type GetMessagesSuspenseQueryHookResult = ReturnType<typeof useGetMessagesSuspenseQuery>;
export type GetMessagesQueryResult = Apollo.QueryResult<
GetMessagesQuery,
GetMessagesQueryVariables
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -31,31 +31,31 @@
"watch-build": "npx tsc-watch --project tsconfig.json --onSuccess \"bob build\""
},
"devDependencies": {
"@babel/core": "7.23.0",
"@babel/preset-env": "7.22.20",
"@babel/preset-typescript": "7.23.0",
"@changesets/changelog-github": "0.4.8",
"@changesets/cli": "2.26.2",
"@babel/core": "7.23.9",
"@babel/preset-env": "7.23.9",
"@babel/preset-typescript": "7.23.3",
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.1",
"@theguild/prettier-config": "1.1.2",
"@types/jest": "28.1.8",
"@types/node": "18.18.0",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@types/node": "20.11.16",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"babel-jest": "28.1.3",
"bob-the-bundler": "7.0.1",
"eslint": "8.35.0",
"eslint-plugin-import": "2.28.1",
"eslint": "8.56.0",
"eslint-plugin-import": "2.29.1",
"graphql": "16.8.1",
"husky": "8.0.3",
"husky": "9.0.10",
"jest": "28.1.3",
"jest-docblock": "28.1.1",
"jest-junit": "16.0.0",
"lint-staged": "14.0.1",
"lint-staged": "15.2.2",
"patch-package": "8.0.0",
"prettier": "2.8.5",
"rimraf": "5.0.2",
"rimraf": "5.0.5",
"ts-jest": "28.0.8",
"ts-node": "10.9.1",
"ts-node": "10.9.2",
"tslib": "2.6.2",
"typescript": "4.9.5"
},
@@ -65,7 +65,7 @@
"graphql-language-service-interface": "2.10.2",
"jest-runner": "28.1.3",
"prettier": "2.8.5",
"ts-node": "10.9.1"
"ts-node": "10.9.2"
},
"lint-staged": {
"packages/**/src/**/*.{ts,tsx}": [
2 changes: 1 addition & 1 deletion packages/plugins/java/apollo-android/package.json
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@
},
"devDependencies": {
"@graphql-codegen/testing": "1.18.0",
"@types/pluralize": "0.0.31"
"@types/pluralize": "0.0.33"
},
"publishConfig": {
"directory": "dist",
9 changes: 9 additions & 0 deletions packages/plugins/java/kotlin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @graphql-codegen/kotlin

## 3.0.1

### Patch Changes

- [#606](https://github.com/dotansimha/graphql-code-generator-community/pull/606)
[`926f515`](https://github.com/dotansimha/graphql-code-generator-community/commit/926f515e242e128d3bc82fa010cf8b2a01c20c7c)
Thanks [@tristanlins](https://github.com/tristanlins)! - fix(kotlin) Omit typesSuffix in enum
names.

## 3.0.0

### Major Changes
2 changes: 1 addition & 1 deletion packages/plugins/java/kotlin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/kotlin",
"version": "3.0.0",
"version": "3.0.1",
"type": "module",
"description": "GraphQL Code Generator plugin for generating Kotlin code based on a GraphQL schema",
"repository": {
1 change: 1 addition & 0 deletions packages/plugins/java/kotlin/src/visitor.ts
Original file line number Diff line number Diff line change
@@ -88,6 +88,7 @@ export class KotlinResolversVisitor extends BaseVisitor<
return indent(
`${this.convertName(node, {
useTypesPrefix: false,
useTypesSuffix: false,
transformUnderscore: true,
})}("${this.getEnumValue(enumName, node.name.value)}")`,
);
46 changes: 46 additions & 0 deletions packages/plugins/java/kotlin/tests/kotlin.spec.ts
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ describe('Kotlin', () => {
username: String
email: String
name: String
role: UserRole = USER
sort: ResultSort
metadata: MetadataSearch
}
@@ -154,6 +155,49 @@ describe('Kotlin', () => {
}
}`);
});

it('Should omit typesPrefix/typesSuffix in enum names if the option is set', async () => {
const result = await plugin(
schema,
[],
{ typesPrefix: 'Graphql', typesSuffix: 'Type' },
{ outputFile: OUTPUT_FILE },
);

// language=kotlin
expect(result).toBeSimilarStringTo(` enum class GraphqlUserRoleType(val label: String) {
Admin("ADMIN"),
User("USER"),
Editor("EDITOR");
companion object {
@JvmStatic
fun valueOfLabel(label: String): GraphqlUserRoleType? {
return values().find { it.label == label }
}
}
}`);

// language=kotlin
expect(result).toBeSimilarStringTo(`data class GraphqlSearchUserTypeInput(
val username: String? = null,
val email: String? = null,
val name: String? = null,
val role: GraphqlUserRoleType? = GraphqlUserRoleType.USER,
val sort: GraphqlResultSortType? = null,
val metadata: GraphqlMetadataSearchTypeInput? = null
) {
@Suppress("UNCHECKED_CAST")
constructor(args: Map<String, Any>) : this(
args["username"] as String?,
args["email"] as String?,
args["name"] as String?,
args["role"] as GraphqlUserRoleType? ?: GraphqlUserRoleType.USER,
args["sort"] as GraphqlResultSortType?,
args["metadata"]?.let { GraphqlMetadataSearchTypeInput(it as Map<String, Any>) }
)
}`);
});
});

describe('Input Types / Arguments', () => {
@@ -243,6 +287,7 @@ describe('Kotlin', () => {
val username: String? = null,
val email: String? = null,
val name: String? = null,
val role: UserRole? = UserRole.USER,
val sort: ResultSort? = null,
val metadata: MetadataSearchInput? = null
) {
@@ -251,6 +296,7 @@ describe('Kotlin', () => {
args["username"] as String?,
args["email"] as String?,
args["name"] as String?,
args["role"] as UserRole? ?: UserRole.USER,
args["sort"] as ResultSort?,
args["metadata"]?.let { MetadataSearchInput(it as Map<String, Any>) }
)
9 changes: 9 additions & 0 deletions packages/plugins/other/hasura-allow-list/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @graphql-codegen/hasura-allow-list

## 3.1.0

### Minor Changes

- [#452](https://github.com/dotansimha/graphql-code-generator-community/pull/452)
[`0fea1a83e`](https://github.com/dotansimha/graphql-code-generator-community/commit/0fea1a83eaf42f56ea68ed5f763fe00f2df7417a)
Thanks [@shoma-mano](https://github.com/shoma-mano)! - add config to change fragments definition
order

## 3.0.0

### Major Changes
2 changes: 1 addition & 1 deletion packages/plugins/other/hasura-allow-list/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/hasura-allow-list",
"version": "3.0.0",
"version": "3.1.0",
"type": "module",
"description": "GraphQL Code Generator plugin to generate hasura allow liste metadata from graphql files",
"repository": {
5 changes: 5 additions & 0 deletions packages/plugins/other/hasura-allow-list/src/config.ts
Original file line number Diff line number Diff line change
@@ -16,4 +16,9 @@ export interface HasuraAllowListPluginConfig {
* @description Whether to source fragments per-document, or globally. If set, will enforce fragment name uniqueness
*/
globalFragments?: boolean;
/**
* @default definition
* @description Whether to order fragments by global definition order, or by definition order in the document
*/
fragmentsOrder?: 'global' | 'document';
}
15 changes: 13 additions & 2 deletions packages/plugins/other/hasura-allow-list/src/index.ts
Original file line number Diff line number Diff line change
@@ -24,13 +24,23 @@ function getOperationFragmentsRecursively(
operationDefinition: OperationDefinitionNode,
fragmentDefinitions: FragmentDefinitionNode[],
documentLocation: string,
config: HasuraAllowListPluginConfig,
): FragmentDefinitionNode[] {
const requiredFragmentNames = new Set<string>();

getRequiredFragments(operationDefinition);

// note: we first get a list of required fragments names, then filter the original list.
// this means order of fragments is preserved.
// note: we should choose fragmentsOrder config that is compatible with other graphql-codegen plugins we use.
const order = config.fragmentsOrder ?? 'global';

// order of fragments is determined by the order they are defined in the document.
if (order === 'document') {
return Array.from(requiredFragmentNames).map(name =>
fragmentDefinitions.find(definition => definition.name.value === name),
);
}

// order is determined by the global fragments definition order.
return fragmentDefinitions.filter(definition => requiredFragmentNames.has(definition.name.value));

/**
@@ -147,6 +157,7 @@ export const plugin: PluginFunction<HasuraAllowListPluginConfig> = async (
operation,
fragments,
document.location,
config,
);

// insert the operation and any fragments to our queries definition.
Original file line number Diff line number Diff line change
@@ -349,6 +349,50 @@ describe('Hasura allow list', () => {

expect(content).toBe(expectedContent);
});
it('with globalFragments enabled and fragmentsOrder set to document, should define fragment by the order they are defined in the document.', async () => {
const expectedContent = `- name: allowed-queries
definition:
queries:
- name: MyQuery1
query: |-
query MyQuery1 {
field
...MyOtherFragment
...MyFragment
}
fragment MyOtherFragment on Query {
field
}
fragment MyFragment on Query {
field
}
`;
const document1 = parse(/* GraphQL */ `
query MyQuery1 {
field
...MyOtherFragment
...MyFragment
}
fragment MyFragment on Query {
field
}
`);
const document2 = parse(/* GraphQL */ `
fragment MyOtherFragment on Query {
field
}
`);
const content = await plugin(
null,
[
{ document: document1, location: '/dummy/location1' },
{ document: document2, location: '/dummy/location2' },
],
{ globalFragments: true, fragmentsOrder: 'document' },
);

expect(content).toBe(expectedContent);
});
it('with globalFragments enabled, should error on missing fragments', async () => {
const document1 = parse(/* GraphQL */ `
query MyQuery1 {
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@
"tslib": "~2.6.0"
},
"devDependencies": {
"@apollo/client": "3.8.4"
"@apollo/client": "3.9.2"
},
"publishConfig": {
"directory": "dist",
9 changes: 9 additions & 0 deletions packages/plugins/typescript/generic-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @graphql-codegen/typescript-generic-sdk

## 4.0.1

### Patch Changes

- [#613](https://github.com/dotansimha/graphql-code-generator-community/pull/613)
[`ae45d38`](https://github.com/dotansimha/graphql-code-generator-community/commit/ae45d38eb0cd32743fda855d131bc4ea8b117568)
Thanks [@j0k3r](https://github.com/j0k3r)! - Fix unused parameter in generated code which caused
TS errors for users of the package.

## 4.0.0

### Major Changes
2 changes: 1 addition & 1 deletion packages/plugins/typescript/generic-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript-generic-sdk",
"version": "4.0.0",
"version": "4.0.1",
"type": "module",
"description": "GraphQL Code Generator plugin for generating a ready-to-use client-agnostic SDK based on GraphQL operations",
"repository": {
20 changes: 15 additions & 5 deletions packages/plugins/typescript/generic-sdk/src/visitor.ts
Original file line number Diff line number Diff line change
@@ -137,17 +137,27 @@ export class GenericSdkVisitor extends ClientSideBaseVisitor<

const documentNodeType =
this.config.documentMode === DocumentMode.string ? 'string' : 'DocumentNode';
const resultData = this.config.rawRequest ? 'ExecutionResult<R, E>' : 'R';
const returnType = `Promise<${resultData}> | ${
usingObservable ? 'Observable' : 'AsyncIterable'
}<${resultData}>`;

return `export type Requester<C = {}, E = unknown> = <R, V>(doc: ${documentNodeType}, vars?: V, options?: C) => ${returnType}
if (this.config.rawRequest) {
return `export type Requester<C = {}, E = unknown> = <R, V>(doc: ${documentNodeType}, vars?: V, options?: C) => Promise<ExecutionResult<R, E>> | ${
usingObservable ? 'Observable' : 'AsyncIterable'
}<ExecutionResult<R, E>>
export function getSdk<C, E>(requester: Requester<C, E>) {
return {
${allPossibleActions.join(',\n')}
};
}
export type Sdk = ReturnType<typeof getSdk>;`;
}

return `export type Requester<C = {}> = <R, V>(doc: ${documentNodeType}, vars?: V, options?: C) => Promise<R> | ${
usingObservable ? 'Observable' : 'AsyncIterable'
}<R>
export function getSdk<C>(requester: Requester<C>) {
return {
${allPossibleActions.join(',\n')}
};
}
export type Sdk = ReturnType<typeof getSdk>;`;
}
}
Original file line number Diff line number Diff line change
@@ -237,8 +237,8 @@ export const Feed4Document = gql\`
}
}
\`;
export type Requester<C = {}, E = unknown> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<R> | AsyncIterable<R>
export function getSdk<C, E>(requester: Requester<C, E>) {
export type Requester<C = {}> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<R> | AsyncIterable<R>
export function getSdk<C>(requester: Requester<C>) {
return {
feed(variables?: FeedQueryVariables, options?: C): Promise<FeedQuery> {
return requester<FeedQuery, FeedQueryVariables>(FeedDocument, variables, options) as Promise<FeedQuery>;
@@ -486,8 +486,8 @@ export const FeedLiveDocument = gql\`
}
}
\`;
export type Requester<C = {}, E = unknown> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<R> | AsyncIterable<R>
export function getSdk<C, E>(requester: Requester<C, E>) {
export type Requester<C = {}> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<R> | AsyncIterable<R>
export function getSdk<C>(requester: Requester<C>) {
return {
feed(variables?: FeedQueryVariables, options?: C): Promise<FeedQuery> {
return requester<FeedQuery, FeedQueryVariables>(FeedDocument, variables, options) as Promise<FeedQuery>;
@@ -726,8 +726,8 @@ export const FeedLiveDocument = gql\`
}
}
\`;
export type Requester<C = {}, E = unknown> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<R> | Observable<R>
export function getSdk<C, E>(requester: Requester<C, E>) {
export type Requester<C = {}> = <R, V>(doc: DocumentNode, vars?: V, options?: C) => Promise<R> | Observable<R>
export function getSdk<C>(requester: Requester<C>) {
return {
feed(variables?: FeedQueryVariables, options?: C): Promise<FeedQuery> {
return requester<FeedQuery, FeedQueryVariables>(FeedDocument, variables, options) as Promise<FeedQuery>;
@@ -978,8 +978,8 @@ export const Feed4Document = \`
}
}
\`;
export type Requester<C = {}, E = unknown> = <R, V>(doc: string, vars?: V, options?: C) => Promise<R> | AsyncIterable<R>
export function getSdk<C, E>(requester: Requester<C, E>) {
export type Requester<C = {}> = <R, V>(doc: string, vars?: V, options?: C) => Promise<R> | AsyncIterable<R>
export function getSdk<C>(requester: Requester<C>) {
return {
feed(variables?: FeedQueryVariables, options?: C): Promise<FeedQuery> {
return requester<FeedQuery, FeedQueryVariables>(FeedDocument, variables, options) as Promise<FeedQuery>;
4 changes: 2 additions & 2 deletions packages/plugins/typescript/graphql-apollo/package.json
Original file line number Diff line number Diff line change
@@ -48,11 +48,11 @@
"tslib": "~2.6.0"
},
"devDependencies": {
"@apollo/client": "3.8.4",
"@apollo/client": "3.9.2",
"@graphql-codegen/core": "2.6.3",
"@graphql-codegen/testing": "1.18.0",
"@graphql-codegen/typescript-operations": "2.5.6",
"@graphql-tools/schema": "10.0.0",
"@graphql-tools/schema": "10.0.2",
"cross-fetch": "3.1.8",
"react": "18.2.0"
},
39 changes: 39 additions & 0 deletions packages/plugins/typescript/graphql-request/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# @graphql-codegen/typescript-graphql-request

## 6.2.0

### Minor Changes

- [#549](https://github.com/dotansimha/graphql-code-generator-community/pull/549)
[`ad8258c`](https://github.com/dotansimha/graphql-code-generator-community/commit/ad8258c66edd732a1b5ef2536021f06e44219daa)
Thanks [@pentla](https://github.com/pentla)! - Fix TypeScript error when moduleResolution is
"nodenext" or "bundler"

### Patch Changes

- [#559](https://github.com/dotansimha/graphql-code-generator-community/pull/559)
[`64c2c10`](https://github.com/dotansimha/graphql-code-generator-community/commit/64c2c10e82b1efe6a8ea7a3c4d9ed5b340945503)
Thanks [@mtlewis](https://github.com/mtlewis)! - Fix unused parameter in generated code which
caused TS errors for users of the package.

## 6.1.0

### Minor Changes

- [#512](https://github.com/dotansimha/graphql-code-generator-community/pull/512)
[`34cdb37`](https://github.com/dotansimha/graphql-code-generator-community/commit/34cdb37247fdf8002176b0e63e8c5bce32f02f24)
Thanks [@axe-me](https://github.com/axe-me)! - pass variables to wrapper function

### Patch Changes

- [#517](https://github.com/dotansimha/graphql-code-generator-community/pull/517)
[`bcd2324`](https://github.com/dotansimha/graphql-code-generator-community/commit/bcd232493d205d21b57e98b8ce83e74b081ad13f)
Thanks [@benjie](https://github.com/benjie)! - Add `.mts` and `.cts` as allowable extensions to
graphql-request

## 6.0.1

### Patch Changes

- [#462](https://github.com/dotansimha/graphql-code-generator-community/pull/462)
[`f7170557e`](https://github.com/dotansimha/graphql-code-generator-community/commit/f7170557ed325af4224447ec041fc10f04ccc5b1)
Thanks [@yshrsmz](https://github.com/yshrsmz)! - fix(graphql-request): add import for GraphQLError

## 6.0.0

### Major Changes
4 changes: 2 additions & 2 deletions packages/plugins/typescript/graphql-request/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript-graphql-request",
"version": "6.0.0",
"version": "6.2.0",
"type": "module",
"description": "GraphQL Code Generator plugin for generating a ready-to-use SDK based on graphql-request and GraphQL operations",
"repository": {
@@ -49,7 +49,7 @@
},
"devDependencies": {
"@graphql-codegen/testing": "1.18.0",
"@graphql-tools/schema": "10.0.0",
"@graphql-tools/schema": "10.0.2",
"graphql-request": "6.0.0"
},
"publishConfig": {
6 changes: 4 additions & 2 deletions packages/plugins/typescript/graphql-request/src/index.ts
Original file line number Diff line number Diff line change
@@ -46,8 +46,10 @@ export const validate: PluginValidateFn<any> = async (
config: RawClientSideBasePluginConfig,
outputFile: string,
) => {
if (extname(outputFile) !== '.ts') {
throw new Error(`Plugin "typescript-graphql-request" requires extension to be ".ts"!`);
if (!['.ts', '.mts', '.cts'].includes(extname(outputFile))) {
throw new Error(
`Plugin "typescript-graphql-request" requires extension to be ".ts", ".mts" or ".cts"!`,
);
}
};

25 changes: 15 additions & 10 deletions packages/plugins/typescript/graphql-request/src/visitor.ts
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ export interface GraphQLRequestPluginConfig extends ClientSideBasePluginConfig {
}

const additionalExportedTypes = `
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
export type SdkFunctionWrapper = <T>(action: (requestHeaders?:Record<string, string>) => Promise<T>, operationName: string, operationType?: string, variables?: any) => Promise<T>;
`;

export class GraphQLRequestVisitor extends ClientSideBaseVisitor<
@@ -45,18 +45,23 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor<
autoBind(this);

const typeImport = this.config.useTypeImports ? 'import type' : 'import';
const fileExtension = this.config.emitLegacyCommonJSImports ? '' : '.js';
const buildPath = this.config.emitLegacyCommonJSImports ? 'cjs' : 'esm';

this._additionalImports.push(`${typeImport} { GraphQLClient } from 'graphql-request';`);
this._additionalImports.push(
`${typeImport} { GraphQLClientRequestHeaders } from 'graphql-request/build/${buildPath}/types${fileExtension}';`,
`${typeImport} { GraphQLClient, RequestOptions } from 'graphql-request';`,
);

if (this.config.rawRequest && this.config.documentMode !== DocumentMode.string) {
this._additionalImports.push(`import { print } from 'graphql'`);
if (this.config.rawRequest) {
if (this.config.documentMode !== DocumentMode.string) {
this._additionalImports.push(`import { GraphQLError, print } from 'graphql'`);
} else {
this._additionalImports.push(`import { GraphQLError } from 'graphql'`);
}
}

this._additionalImports.push(
`type GraphQLClientRequestHeaders = RequestOptions['requestHeaders'];`,
);

this._externalImportPrefix = this.config.importOperationTypesFrom
? `${this.config.importOperationTypesFrom}.`
: '';
@@ -134,23 +139,23 @@ export class GraphQLRequestVisitor extends ClientSideBaseVisitor<
}; headers: Headers; status: number; }> {
return withWrapper((wrappedRequestHeaders) => client.rawRequest<${
o.operationResultType
}>(${docArg}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}');
}>(${docArg}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}', variables);
}`;
}
return `${operationName}(variables${optionalVariables ? '?' : ''}: ${
o.operationVariablesTypes
}, requestHeaders?: GraphQLClientRequestHeaders): Promise<${o.operationResultType}> {
return withWrapper((wrappedRequestHeaders) => client.request<${
o.operationResultType
}>(${docVarName}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}');
}>(${docVarName}, variables, {...requestHeaders, ...wrappedRequestHeaders}), '${operationName}', '${operationType}', variables);
}`;
})
.filter(Boolean)
.map(s => indentMultiline(s, 2));

return `${additionalExportedTypes}
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType) => action();
const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationType, _variables) => action();
${extraVariables.join('\n')}
export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
return {

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ async function test() {
const output = await validate(result, config, docs, schema, usage);

expect(result.content).toContain(
`(FeedDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed', 'query');`,
`(FeedDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed', 'query', variables);`,
);
expect(output).toMatchSnapshot();
});
@@ -272,6 +272,36 @@ async function test() {
const result = await sdk.feed2({ v: "1" });
if (result.feed) {
if (result.feed[0]) {
const id = result.feed[0].id
}
}
}`;
const output = await validate(result, config, docs, schema, usage);

expect(output).toMatchSnapshot();
});

it('Should only import GraphQLError when rawRequest is true and documentMode = "string"', async () => {
const config = { rawRequest: true, documentMode: DocumentMode.string };
const docs = [{ location: '', document: basicDoc }];
const result = (await plugin(schema, docs, config, {
outputFile: 'graphql.ts',
})) as Types.ComplexPluginOutput;

const usage = `
async function test() {
const Client = require('graphql-request').GraphQLClient;
const client = new Client('');
const sdk = getSdk(client);
await sdk.feed();
await sdk.feed3();
await sdk.feed4();
const result = await sdk.feed2({ v: "1" });
if (result.feed) {
if (result.feed[0]) {
const id = result.feed[0].id
@@ -377,13 +407,13 @@ async function test() {

expect(output).toContain(`import * as Operations from './operations';`);
expect(output).toContain(
`(Operations.FeedDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed', 'query');`,
`(Operations.FeedDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed', 'query', variables);`,
);
expect(output).toContain(
`(Operations.Feed2Document, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed2', 'query');`,
`(Operations.Feed2Document, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed2', 'query', variables);`,
);
expect(output).toContain(
`(Operations.Feed3Document, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed3', 'query');`,
`(Operations.Feed3Document, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'feed3', 'query', variables);`,
);
});

2 changes: 1 addition & 1 deletion packages/plugins/typescript/jit-sdk/package.json
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
"tslib": "~2.6.0"
},
"devDependencies": {
"@graphql-tools/utils": "10.0.6",
"@graphql-tools/utils": "10.0.13",
"graphql-jit": "0.8.4"
},
"publishConfig": {
2 changes: 1 addition & 1 deletion packages/plugins/typescript/mongodb/package.json
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@
},
"devDependencies": {
"@graphql-codegen/testing": "1.18.0",
"@types/lodash": "4.14.199"
"@types/lodash": "4.14.202"
},
"publishConfig": {
"directory": "dist",
18 changes: 18 additions & 0 deletions packages/plugins/typescript/msw/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @graphql-codegen/typescript-msw

## 3.0.0

### Major Changes

- [#594](https://github.com/dotansimha/graphql-code-generator-community/pull/594)
[`40f3676`](https://github.com/dotansimha/graphql-code-generator-community/commit/40f3676ae8799b61fb564cf4f1f51a6724e6dea8)
Thanks [@lachieh](https://github.com/lachieh)! - Corrected compatibility with `msw@^2`. Types used
are incompatible with `msw@^1`.

## 2.1.0

### Minor Changes

- [#484](https://github.com/dotansimha/graphql-code-generator-community/pull/484)
[`1f056e99c`](https://github.com/dotansimha/graphql-code-generator-community/commit/1f056e99c18d36557fac4f3c75a52ee9c2a7bfb2)
Thanks [@netanelgilad](https://github.com/netanelgilad)! - future proof types for generated mock
functions - this also adds support for `msw@2`.

## 2.0.0

### Major Changes
5 changes: 3 additions & 2 deletions packages/plugins/typescript/msw/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript-msw",
"version": "2.0.0",
"version": "3.0.0",
"type": "module",
"description": "GraphQL Code Generator plugin for generating MSW mock handlers based on GraphQL operations",
"repository": {
@@ -37,7 +37,8 @@
"test": "jest --no-watchman --config ../../../../jest.config.js"
},
"peerDependencies": {
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
"msw": "^2.0.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^3.0.0",
31 changes: 20 additions & 11 deletions packages/plugins/typescript/msw/src/visitor.ts
Original file line number Diff line number Diff line change
@@ -44,7 +44,9 @@ export class MSWVisitor extends ClientSideBaseVisitor<MSWRawPluginConfig, MSWPlu
return [];
}

return [`import { graphql, ResponseResolver, GraphQLRequest, GraphQLContext } from 'msw'`];
return [
`import { graphql, type GraphQLResponseResolver, type RequestHandlerOptions } from 'msw'`,
];
}

public getContent() {
@@ -69,23 +71,30 @@ export class MSWVisitor extends ClientSideBaseVisitor<MSWRawPluginConfig, MSWPlu
const variables = node.variableDefinitions.map(def => def.variable.name.value).join(', ');

return `/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* ${handlerName}((req, res, ctx) => {${
variables && `\n * const { ${variables} } = req.variables;`
}
* return res(
* ctx.data({ ${selections} })
* )
* })
* ${handlerName}(
* ({ query, variables }) => {${
variables &&
`
* const { ${variables} } = variables;`
}
* return HttpResponse.json({
* data: { ${selections} }
* })
* },
* requestOptions
* )
*/
export const ${handlerName} = (resolver: ResponseResolver<GraphQLRequest<${operationVariablesTypes}>, GraphQLContext<${operationResultType}>, any>) =>
export const ${handlerName} = (resolver: GraphQLResponseResolver<${operationResultType}, ${operationVariablesTypes}>, options?: RequestHandlerOptions) =>
${
link?.name || 'graphql'
}.${operationType.toLowerCase()}<${operationResultType}, ${operationVariablesTypes}>(
'${node.name.value}',
resolver
resolver,
options
)\n`;
}
return '';
216 changes: 133 additions & 83 deletions packages/plugins/typescript/msw/tests/__snapshots__/msw.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -3,37 +3,47 @@
exports[`msw Should generate JSDoc documentation with variables and selection from the operations themselves: content with variables and selection JSDoc documentation 1`] = `
"
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUserQuery((req, res, ctx) => {
* const { id, offset, limit } = req.variables;
* return res(
* ctx.data({ name, phone, country })
* )
* })
* mockUserQuery(
* ({ query, variables }) => {
* const { id, offset, limit } = variables;
* return HttpResponse.json({
* data: { name, phone, country }
* })
* },
* requestOptions
* )
*/
export const mockUserQuery = (resolver: ResponseResolver<GraphQLRequest<UserQueryVariables>, GraphQLContext<UserQuery>, any>) =>
export const mockUserQuery = (resolver: GraphQLResponseResolver<UserQuery, UserQueryVariables>, options?: RequestHandlerOptions) =>
graphql.query<UserQuery, UserQueryVariables>(
'User',
resolver
resolver,
options
)
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUpdateUserMutation((req, res, ctx) => {
* const { id, offset, limit } = req.variables;
* return res(
* ctx.data({ name, phone, country })
* )
* })
* mockUpdateUserMutation(
* ({ query, variables }) => {
* const { id, offset, limit } = variables;
* return HttpResponse.json({
* data: { name, phone, country }
* })
* },
* requestOptions
* )
*/
export const mockUpdateUserMutation = (resolver: ResponseResolver<GraphQLRequest<UpdateUserMutationVariables>, GraphQLContext<UpdateUserMutation>, any>) =>
export const mockUpdateUserMutation = (resolver: GraphQLResponseResolver<UpdateUserMutation, UpdateUserMutationVariables>, options?: RequestHandlerOptions) =>
graphql.mutation<UpdateUserMutation, UpdateUserMutationVariables>(
'UpdateUser',
resolver
resolver,
options
)
"
`;
@@ -42,35 +52,45 @@ exports[`msw Should generate a link with an endpoint when passed a link variable
"const api = graphql.link('http://localhost:3000/graphql')
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUserQueryApi((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUserQueryApi(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUserQueryApi = (resolver: ResponseResolver<GraphQLRequest<UserQueryVariables>, GraphQLContext<UserQuery>, any>) =>
export const mockUserQueryApi = (resolver: GraphQLResponseResolver<UserQuery, UserQueryVariables>, options?: RequestHandlerOptions) =>
api.query<UserQuery, UserQueryVariables>(
'User',
resolver
resolver,
options
)
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUpdateUserMutationApi((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUpdateUserMutationApi(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUpdateUserMutationApi = (resolver: ResponseResolver<GraphQLRequest<UpdateUserMutationVariables>, GraphQLContext<UpdateUserMutation>, any>) =>
export const mockUpdateUserMutationApi = (resolver: GraphQLResponseResolver<UpdateUserMutation, UpdateUserMutationVariables>, options?: RequestHandlerOptions) =>
api.mutation<UpdateUserMutation, UpdateUserMutationVariables>(
'UpdateUser',
resolver
resolver,
options
)
"
`;
@@ -79,113 +99,143 @@ exports[`msw Should generate handlerNames without suffix when withSuffix is fals
"const api = graphql.link('http://localhost:3000/graphql')
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUserQuery((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUserQuery(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUserQuery = (resolver: ResponseResolver<GraphQLRequest<UserQueryVariables>, GraphQLContext<UserQuery>, any>) =>
export const mockUserQuery = (resolver: GraphQLResponseResolver<UserQuery, UserQueryVariables>, options?: RequestHandlerOptions) =>
api.query<UserQuery, UserQueryVariables>(
'User',
resolver
resolver,
options
)
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUpdateUserMutation((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUpdateUserMutation(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUpdateUserMutation = (resolver: ResponseResolver<GraphQLRequest<UpdateUserMutationVariables>, GraphQLContext<UpdateUserMutation>, any>) =>
export const mockUpdateUserMutation = (resolver: GraphQLResponseResolver<UpdateUserMutation, UpdateUserMutationVariables>, options?: RequestHandlerOptions) =>
api.mutation<UpdateUserMutation, UpdateUserMutationVariables>(
'UpdateUser',
resolver
resolver,
options
)
"
`;

exports[`msw Should generate mocks based on queries and mutations: content 1`] = `
"
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUserQuery((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUserQuery(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUserQuery = (resolver: ResponseResolver<GraphQLRequest<UserQueryVariables>, GraphQLContext<UserQuery>, any>) =>
export const mockUserQuery = (resolver: GraphQLResponseResolver<UserQuery, UserQueryVariables>, options?: RequestHandlerOptions) =>
graphql.query<UserQuery, UserQueryVariables>(
'User',
resolver
resolver,
options
)
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUpdateUserMutation((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUpdateUserMutation(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUpdateUserMutation = (resolver: ResponseResolver<GraphQLRequest<UpdateUserMutationVariables>, GraphQLContext<UpdateUserMutation>, any>) =>
export const mockUpdateUserMutation = (resolver: GraphQLResponseResolver<UpdateUserMutation, UpdateUserMutationVariables>, options?: RequestHandlerOptions) =>
graphql.mutation<UpdateUserMutation, UpdateUserMutationVariables>(
'UpdateUser',
resolver
resolver,
options
)
"
`;

exports[`msw Should generate mocks based on queries and mutations: imports 1`] = `
[
"import { graphql, ResponseResolver, GraphQLRequest, GraphQLContext } from 'msw'",
"import { graphql, type GraphQLResponseResolver, type RequestHandlerOptions } from 'msw'",
]
`;

exports[`msw Should use the "importOperationTypesFrom" setting: content with types configured via importOperationTypesFrom 1`] = `
"
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUserQuery((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUserQuery(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUserQuery = (resolver: ResponseResolver<GraphQLRequest<Types.UserQueryVariables>, GraphQLContext<Types.UserQuery>, any>) =>
export const mockUserQuery = (resolver: GraphQLResponseResolver<Types.UserQuery, Types.UserQueryVariables>, options?: RequestHandlerOptions) =>
graphql.query<Types.UserQuery, Types.UserQueryVariables>(
'User',
resolver
resolver,
options
)
/**
* @param resolver a function that accepts a captured request and may return a mocked response.
* @param resolver A function that accepts [resolver arguments](https://mswjs.io/docs/api/graphql#resolver-argument) and must always return the instruction on what to do with the intercepted request. ([see more](https://mswjs.io/docs/concepts/response-resolver#resolver-instructions))
* @param options Options object to customize the behavior of the mock. ([see more](https://mswjs.io/docs/api/graphql#handler-options))
* @see https://mswjs.io/docs/basics/response-resolver
* @example
* mockUpdateUserMutation((req, res, ctx) => {
* return res(
* ctx.data({ name })
* )
* })
* mockUpdateUserMutation(
* ({ query, variables }) => {
* return HttpResponse.json({
* data: { name }
* })
* },
* requestOptions
* )
*/
export const mockUpdateUserMutation = (resolver: ResponseResolver<GraphQLRequest<Types.UpdateUserMutationVariables>, GraphQLContext<Types.UpdateUserMutation>, any>) =>
export const mockUpdateUserMutation = (resolver: GraphQLResponseResolver<Types.UpdateUserMutation, Types.UpdateUserMutationVariables>, options?: RequestHandlerOptions) =>
graphql.mutation<Types.UpdateUserMutation, Types.UpdateUserMutationVariables>(
'UpdateUser',
resolver
resolver,
options
)
"
`;
14 changes: 8 additions & 6 deletions packages/plugins/typescript/msw/tests/msw.spec.ts
Original file line number Diff line number Diff line change
@@ -73,8 +73,8 @@ describe('msw', () => {

const result = await plugin(null, documents, {});

expect(result.content).toContain(`const { ${variables.join(', ')} } = req.variables`);
expect(result.content).toContain(`ctx.data({ ${selection} })`);
expect(result.content).toContain(`const { ${variables.join(', ')} } = variables`);
expect(result.content).toContain(`data: { ${selection} }`);
expect(result.content).toMatchSnapshot(
'content with variables and selection JSDoc documentation',
);
@@ -87,14 +87,16 @@ describe('msw', () => {
// handler variable and result type
const queryVariablesType = `${importOperationTypesFrom}.${queryName}QueryVariables`;
const queryType = `${importOperationTypesFrom}.${queryName}Query`;
expect(result.content).toContain(`GraphQLRequest<${queryVariablesType}>`);
expect(result.content).toContain(`GraphQLContext<${queryType}>`);
expect(result.content).toContain(
`GraphQLResponseResolver<${queryType}, ${queryVariablesType}>`,
);
expect(result.content).toContain(`graphql.query<${queryType}, ${queryVariablesType}>`);

const mutationVariablesType = `${importOperationTypesFrom}.${mutationName}MutationVariables`;
const mutationType = `${importOperationTypesFrom}.${mutationName}Mutation`;
expect(result.content).toContain(`GraphQLRequest<${mutationVariablesType}>`);
expect(result.content).toContain(`GraphQLContext<${mutationType}>`);
expect(result.content).toContain(
`GraphQLResponseResolver<${mutationType}, ${mutationVariablesType}>`,
);
expect(result.content).toContain(`graphql.mutation<${mutationType}, ${mutationVariablesType}>`);

expect(result.content).toMatchSnapshot(
10 changes: 10 additions & 0 deletions packages/plugins/typescript/nest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# @graphql-codegen/typescript-nest

## 1.0.0

### Major Changes

- [#548](https://github.com/dotansimha/graphql-code-generator-community/pull/548)
[`cda1ba3`](https://github.com/dotansimha/graphql-code-generator-community/commit/cda1ba3b337f6cef12415c521a11d755a26f9add)
Thanks [@bridges-wood](https://github.com/bridges-wood)! - Add GraphQL Code Generator plugin for
generating NestJS compatible types
1 change: 1 addition & 0 deletions packages/plugins/typescript/nest/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('../../../../jest.project')({ dirname: __dirname });
59 changes: 59 additions & 0 deletions packages/plugins/typescript/nest/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@graphql-codegen/typescript-nest",
"version": "1.0.0",
"type": "module",
"description": "GraphQL Code Generator plugin for generating NestJS compatible types",
"repository": {
"type": "git",
"url": "https://github.com/dotansimha/graphql-code-generator-community.git",
"directory": "packages/plugins/typescript/nest"
},
"license": "MIT",
"engines": {
"node": ">= 16.0.0"
},
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"exports": {
".": {
"require": {
"types": "./dist/typings/index.d.cts",
"default": "./dist/cjs/index.js"
},
"import": {
"types": "./dist/typings/index.d.ts",
"default": "./dist/esm/index.js"
},
"default": {
"types": "./dist/typings/index.d.ts",
"default": "./dist/esm/index.js"
}
},
"./package.json": "./package.json"
},
"typings": "dist/typings/index.d.ts",
"scripts": {
"lint": "eslint **/*.ts",
"test": "jest --no-watchman --config ../../../../jest.config.js"
},
"peerDependencies": {
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
},
"dependencies": {
"@graphql-codegen/plugin-helpers": "^3.0.0",
"@graphql-codegen/typescript": "^2.8.1",
"@graphql-codegen/visitor-plugin-common": "2.13.1",
"auto-bind": "~4.0.0",
"tslib": "~2.6.0"
},
"devDependencies": {
"@graphql-codegen/testing": "1.18.0"
},
"publishConfig": {
"directory": "dist",
"access": "public"
},
"typescript": {
"definition": "dist/typings/index.d.ts"
}
}
34 changes: 34 additions & 0 deletions packages/plugins/typescript/nest/src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { TypeScriptPluginConfig } from '@graphql-codegen/typescript';
import { DecoratorConfig } from './types.js';

export interface NestPluginConfig extends TypeScriptPluginConfig {
/**
* @name decoratorName
* @description allow overriding of Nest decorator types
* @default { type: 'ObjectType', interface: 'InterfaceType', arguments: 'ArgsType', field: 'Field', input: 'InputType' }
*/
decoratorName?: Partial<DecoratorConfig>;

/**
* @name decorateTypes
* @description Specifies the objects that will have Nest decorators prepended to them, by name. Non-matching types will still be output, but without decorators. If not set, all types will be decorated.
* @exampleMarkdown Decorate only type User
* ```ts filename="codegen.ts"
* import type { CodegenConfig } from '@graphql-codegen/cli';
*
* const config: CodegenConfig = {
* // ...
* generates: {
* 'path/to/file.ts': {
* plugins: ['typescript-nest'],
* config: {
* decorateTypes: ['User']
* },
* },
* },
* };
* export default config;
* ```
*/
decorateTypes?: string[];
}
9 changes: 9 additions & 0 deletions packages/plugins/typescript/nest/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const MAYBE_REGEX = /^Maybe<(.*?)>$/;
export const ARRAY_REGEX = /^Array<(.*?)>$/;
export const SCALAR_REGEX = /^Scalars\['(.*?)'\]$/;
export const GRAPHQL_TYPES = ['Query', 'Mutation', 'Subscription'];
export const NEST_SCALARS = ['ID', 'Int', 'Float', 'GraphQLISODateTime', 'GraphQLTimestamp'];
export const FIX_DECORATOR_SIGNATURE = `type FixDecorator<T> = T;`;
export const SCALARS = ['ID', 'String', 'Boolean', 'Int', 'Float'];
export const NEST_PREFIX = 'Nest';
export const NEST_IMPORT = `import * as ${NEST_PREFIX} from '@nestjs/graphql';\nexport { ${NEST_PREFIX} };`;
41 changes: 41 additions & 0 deletions packages/plugins/typescript/nest/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { GraphQLSchema } from 'graphql';
import {
getCachedDocumentNodeFromSchema,
oldVisit,
PluginFunction,
Types,
} from '@graphql-codegen/plugin-helpers';
import {
includeIntrospectionTypesDefinitions,
TsIntrospectionVisitor,
} from '@graphql-codegen/typescript';
import { NestPluginConfig } from './config.js';
import { NEST_IMPORT } from './constants.js';
import { isDefinitionInterface } from './utils.js';
import { NestVisitor } from './visitor.js';

export const plugin: PluginFunction<Partial<NestPluginConfig>, Types.ComplexPluginOutput> = (
schema: GraphQLSchema,
documents: Types.DocumentFile[],
config: NestPluginConfig,
) => {
const visitor = new NestVisitor(schema, config);
const astNode = getCachedDocumentNodeFromSchema(schema);
const visitorResult = oldVisit(astNode, { leave: visitor });
const introspectionDefinitions = includeIntrospectionTypesDefinitions(schema, documents, config);
const scalars = visitor.scalarsDefinition;

const { definitions } = visitorResult;
// Sort output by interfaces first, classes last to prevent TypeScript errors
definitions.sort(
(definition1, definition2) =>
+isDefinitionInterface(definition2) - +isDefinitionInterface(definition1),
);

return {
prepend: [...visitor.getEnumsImports(), ...visitor.getWrapperDefinitions(), NEST_IMPORT],
content: [scalars, ...definitions, ...introspectionDefinitions].join('\n'),
};
};

export { TsIntrospectionVisitor };
21 changes: 21 additions & 0 deletions packages/plugins/typescript/nest/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export type DecoratorConfig = {
type: string;
interface: string;
field: string;
input: string;
arguments: string;
};

export type DecoratorOptions = {
nullable?: string;
description?: string;
implements?: string;
};

export interface Type {
type: string;
isNullable: boolean;
isArray: boolean;
isScalar: boolean;
isItemsNullable: boolean;
}
62 changes: 62 additions & 0 deletions packages/plugins/typescript/nest/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { DecoratorOptions, Type } from './types.js';

export const isDefinitionInterface = definition => definition.includes('@Nest.InterfaceType()');

export const escapeString = (str: string) =>
"'" +
String(str || '')
.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'") +
"'";

export const formatDecoratorOptions = (options: DecoratorOptions, isFirstArgument = true) => {
if (!Object.keys(options).length) {
return '';
}

return (
(isFirstArgument ? '' : ', ') +
('{ ' +
Object.entries(options)
.map(([key, value]) => `${key}: ${JSON.stringify(value).replace(/"/g, '')}`)
.join(', ') +
' }')
);
};

export const buildTypeString = (type: Type): string => {
if (!type.isArray && !type.isScalar && !type.isNullable) {
type.type = `FixDecorator<${type.type}>`;
}
if (type.isScalar) {
type.type = `Scalars['${type.type}']`;
}
if (type.isArray) {
type.type = `Array<${type.type}>`;
}
if (type.isNullable) {
type.type = `Maybe<${type.type}>`;
}

return type.type;
};

export const fixDecorator = (type: Type, typeString: string): string => {
return type.isArray || type.isNullable || type.isScalar
? typeString
: `FixDecorator<${typeString}>`;
};

export const getNestNullableValue = (type: Type): string => {
if (type.isNullable) {
if (type.isItemsNullable) {
return "'itemsAndList'";
}
return 'true';
}
if (type.isItemsNullable) {
return "'items'";
}

return undefined;
};
450 changes: 450 additions & 0 deletions packages/plugins/typescript/nest/src/visitor.ts

Large diffs are not rendered by default.

840 changes: 840 additions & 0 deletions packages/plugins/typescript/nest/tests/nest.spec.ts

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions packages/plugins/typescript/react-apollo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# @graphql-codegen/typescript-react-apollo

## 4.2.0

### Minor Changes

- [#483](https://github.com/dotansimha/graphql-code-generator-community/pull/483)
[`ba7e551`](https://github.com/dotansimha/graphql-code-generator-community/commit/ba7e551bd1b9827ceefa05b4b11a900200f3668d)
Thanks [@rickdunkin](https://github.com/rickdunkin)! - Apollo Client `useFragment` hook

### Patch Changes

- [#464](https://github.com/dotansimha/graphql-code-generator-community/pull/464)
[`fa53f8f`](https://github.com/dotansimha/graphql-code-generator-community/commit/fa53f8f63dea02912fdf4153f32c7f2ae28dae83)
Thanks [@namoscato](https://github.com/namoscato)! - fix: loosen defaultBaseOptions type

## 4.1.0

### Minor Changes

- [#392](https://github.com/dotansimha/graphql-code-generator-community/pull/392)
[`d86d2052a`](https://github.com/dotansimha/graphql-code-generator-community/commit/d86d2052a00ac5ca63a3a1140cb1419236c85236)
Thanks [@Hal-ang](https://github.com/Hal-ang)! - feat: support useSuspenseQuery

## 4.0.0

### Major Changes
2 changes: 1 addition & 1 deletion packages/plugins/typescript/react-apollo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graphql-codegen/typescript-react-apollo",
"version": "4.0.0",
"version": "4.2.0",
"type": "module",
"description": "GraphQL Code Generator plugin for generating a ready-to-use React Components/HOC/Hooks based on GraphQL operations",
"repository": {
42 changes: 40 additions & 2 deletions packages/plugins/typescript/react-apollo/src/config.ts
Original file line number Diff line number Diff line change
@@ -217,6 +217,31 @@ export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfi
* ```
*/
withMutationOptionsType?: boolean;

/**
* @description Whether or not to include wrappers for Apollo's useFragment hook.
* @default false
*
* @exampleMarkdown
* ```ts filename="codegen.ts"
* import type { CodegenConfig } from '@graphql-codegen/cli';
*
* const config: CodegenConfig = {
* // ...
* generates: {
* 'path/to/file.ts': {
* plugins: ['typescript', 'typescript-operations', 'typescript-react-apollo'],
* config: {
* withFragmentHooks: true
* },
* },
* },
* };
* export default config;
* ```
*/
withFragmentHooks?: boolean;

/**
* @description Allows you to enable/disable the generation of docblocks in generated code.
* Some IDE's (like VSCode) add extra inline information with docblocks, you can disable this feature if your preferred IDE does not.
@@ -241,8 +266,21 @@ export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfi
* ```
*/
addDocBlocks?: boolean;

defaultBaseOptions?: { [key: string]: string };
/**
* @description Configure default mutation and query hook options.
*/
defaultBaseOptions?: ReactApolloPluginConfigDefaultBaseOptions;

hooksSuffix?: string;
}

export interface ReactApolloPluginConfigDefaultBaseOptions {
awaitRefetchQueries?: boolean;
errorPolicy?: string;
fetchPolicy?: string;
ignoreResults?: boolean;
notifyOnNetworkStatusChange?: boolean;
returnPartialData?: boolean;
ssr?: boolean;
[key: string]: any;
}
85 changes: 82 additions & 3 deletions packages/plugins/typescript/react-apollo/src/visitor.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import {
LoadedFragment,
OMIT_TYPE,
} from '@graphql-codegen/visitor-plugin-common';
import { ReactApolloRawPluginConfig } from './config.js';
import { ReactApolloPluginConfigDefaultBaseOptions, ReactApolloRawPluginConfig } from './config.js';

const APOLLO_CLIENT_3_UNIFIED_PACKAGE = `@apollo/client`;
const GROUPED_APOLLO_CLIENT_3_IDENTIFIER = 'Apollo';
@@ -21,6 +21,7 @@ export interface ReactApolloPluginConfig extends ClientSideBasePluginConfig {
withHooks: boolean;
withMutationFn: boolean;
withRefetchFn: boolean;
withFragmentHooks?: boolean;
apolloReactCommonImportFrom: string;
apolloReactComponentsImportFrom: string;
apolloReactHocImportFrom: string;
@@ -30,7 +31,7 @@ export interface ReactApolloPluginConfig extends ClientSideBasePluginConfig {
withResultType: boolean;
withMutationOptionsType: boolean;
addDocBlocks: boolean;
defaultBaseOptions: { [key: string]: string };
defaultBaseOptions: ReactApolloPluginConfigDefaultBaseOptions;
hooksSuffix: string;
}

@@ -62,6 +63,7 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor<
withHooks: getConfigValue(rawConfig.withHooks, true),
withMutationFn: getConfigValue(rawConfig.withMutationFn, true),
withRefetchFn: getConfigValue(rawConfig.withRefetchFn, false),
withFragmentHooks: getConfigValue(rawConfig.withFragmentHooks, false),
apolloReactCommonImportFrom: getConfigValue(
rawConfig.apolloReactCommonImportFrom,
rawConfig.reactApolloVersion === 2
@@ -192,10 +194,14 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor<
const baseImports = super.getImports();
const hasOperations = this._collectedOperations.length > 0;

if (!hasOperations) {
if (!hasOperations && !this.config.withFragmentHooks) {
return baseImports;
}

if (this.config.withFragmentHooks) {
return [...baseImports, this.getApolloReactHooksImport(false), ...Array.from(this.imports)];
}

return [...baseImports, ...Array.from(this.imports)];
}

@@ -418,6 +424,25 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor<
hookResults.push(
`export type ${lazyOperationName}HookResult = ReturnType<typeof use${lazyOperationName}>;`,
);

const suspenseOperationName: string =
this.convertName(nodeName, {
suffix: pascalCase('SuspenseQuery'),
useTypesPrefix: false,
}) + this.config.hooksSuffix;

hookFns.push(
`export function use${suspenseOperationName}(baseOptions?: ${this.getApolloReactHooksIdentifier()}.SuspenseQueryHookOptions<${operationResultType}, ${operationVariablesTypes}>) {
const options = {...defaultOptions, ...baseOptions}
return ${this.getApolloReactHooksIdentifier()}.useSuspenseQuery<${operationResultType}, ${operationVariablesTypes}>(${this.getDocumentNodeVariable(
node,
documentVariableName,
)}, options);
}`,
);
hookResults.push(
`export type ${suspenseOperationName}HookResult = ReturnType<typeof use${suspenseOperationName}>;`,
);
}

return [...hookFns, ...hookResults].join('\n');
@@ -564,4 +589,58 @@ export class ReactApolloVisitor extends ClientSideBaseVisitor<
.filter(a => a)
.join('\n');
}

public get fragments(): string {
const fragments = super.fragments;

if (this._fragments.length === 0 || !this.config.withFragmentHooks) {
return fragments;
}

const operationType = 'Fragment';

const hookFns: string[] = [fragments];

for (const fragment of this._fragments.values()) {
if (fragment.isExternal) {
continue;
}

const nodeName = fragment.name ?? '';
const suffix = this._getHookSuffix(nodeName, operationType);
const fragmentName: string =
this.convertName(nodeName, {
suffix,
useTypesPrefix: false,
useTypesSuffix: false,
}) + this.config.hooksSuffix;

const operationTypeSuffix: string = this.getOperationSuffix(fragmentName, operationType);

const operationResultType: string = this.convertName(nodeName, {
suffix: operationTypeSuffix + this._parsedConfig.operationResultSuffix,
});

const IDType = this.scalars.ID ?? 'string';

const hook = `export function use${fragmentName}<F = { id: ${IDType} }>(identifiers: F) {
return ${this.getApolloReactHooksIdentifier()}.use${operationType}<${operationResultType}>({
fragment: ${nodeName}${this.config.fragmentVariableSuffix},
fragmentName: "${nodeName}",
from: {
__typename: "${fragment.onType}",
...identifiers,
},
});
}`;

const hookResults = [
`export type ${fragmentName}HookResult = ReturnType<typeof use${fragmentName}>;`,
];

hookFns.push([hook, hookResults].join('\n'));
}

return hookFns.join('\n');
}
}
Original file line number Diff line number Diff line change
@@ -190,8 +190,13 @@ export function useGet_SomethingLazyQuery(baseOptions?: Apollo.LazyQueryHookOpti
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<Types.Get_SomethingQuery, Types.Get_SomethingQueryVariables>(Get_SomethingDocument, options);
}
export function useGet_SomethingSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions<Types.Get_SomethingQuery, Types.Get_SomethingQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSuspenseQuery<Types.Get_SomethingQuery, Types.Get_SomethingQueryVariables>(Get_SomethingDocument, options);
}
export type Get_SomethingQueryHookResult = ReturnType<typeof useGet_SomethingQuery>;
export type Get_SomethingLazyQueryHookResult = ReturnType<typeof useGet_SomethingLazyQuery>;
export type Get_SomethingSuspenseQueryHookResult = ReturnType<typeof useGet_SomethingSuspenseQuery>;
export type Get_SomethingQueryResult = Apollo.QueryResult<Types.Get_SomethingQuery, Types.Get_SomethingQueryVariables>;"
`;
@@ -385,8 +390,13 @@ export function useGet_SomethingLazyQuery(baseOptions?: Apollo.LazyQueryHookOpti
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<GQLGet_SomethingQuery, GQLGet_SomethingQueryVariables>(Get_SomethingDocument, options);
}
export function useGet_SomethingSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions<GQLGet_SomethingQuery, GQLGet_SomethingQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSuspenseQuery<GQLGet_SomethingQuery, GQLGet_SomethingQueryVariables>(Get_SomethingDocument, options);
}
export type Get_SomethingQueryHookResult = ReturnType<typeof useGet_SomethingQuery>;
export type Get_SomethingLazyQueryHookResult = ReturnType<typeof useGet_SomethingLazyQuery>;
export type Get_SomethingSuspenseQueryHookResult = ReturnType<typeof useGet_SomethingSuspenseQuery>;
export type Get_SomethingQueryResult = Apollo.QueryResult<GQLGet_SomethingQuery, GQLGet_SomethingQueryVariables>;"
`;
@@ -580,8 +590,13 @@ export function useGetSomethingLazyQuery(baseOptions?: Apollo.LazyQueryHookOptio
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<GetSomethingQuery, GetSomethingQueryVariables>(GetSomethingDocument, options);
}
export function useGetSomethingSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions<GetSomethingQuery, GetSomethingQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSuspenseQuery<GetSomethingQuery, GetSomethingQueryVariables>(GetSomethingDocument, options);
}
export type GetSomethingQueryHookResult = ReturnType<typeof useGetSomethingQuery>;
export type GetSomethingLazyQueryHookResult = ReturnType<typeof useGetSomethingLazyQuery>;
export type GetSomethingSuspenseQueryHookResult = ReturnType<typeof useGetSomethingSuspenseQuery>;
export type GetSomethingQueryResult = Apollo.QueryResult<GetSomethingQuery, GetSomethingQueryVariables>;"
`;
@@ -775,8 +790,13 @@ export function useGetSomethingLazyQuery(baseOptions?: Apollo.LazyQueryHookOptio
const options = {...defaultOptions, ...baseOptions}
return Apollo.useLazyQuery<GetSomethingQuery, GetSomethingQueryVariables>(GetSomethingDocument, options);
}
export function useGetSomethingSuspenseQuery(baseOptions?: Apollo.SuspenseQueryHookOptions<GetSomethingQuery, GetSomethingQueryVariables>) {
const options = {...defaultOptions, ...baseOptions}
return Apollo.useSuspenseQuery<GetSomethingQuery, GetSomethingQueryVariables>(GetSomethingDocument, options);
}
export type GetSomethingQueryHookResult = ReturnType<typeof useGetSomethingQuery>;
export type GetSomethingLazyQueryHookResult = ReturnType<typeof useGetSomethingLazyQuery>;
export type GetSomethingSuspenseQueryHookResult = ReturnType<typeof useGetSomethingSuspenseQuery>;
export type GetSomethingQueryResult = Apollo.QueryResult<GetSomethingQuery, GetSomethingQueryVariables>;"
`;
Loading