graphql-codegen-plugin-typescript-swr 0.7.2 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/jest.config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { resolve } = require('path')
2
- const { pathsToModuleNameMapper } = require('ts-jest/utils')
2
+ const { pathsToModuleNameMapper } = require('ts-jest')
3
3
 
4
4
  const pkg = require('./package.json')
5
5
  const tsconfig = require('./tsconfig.json')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-codegen-plugin-typescript-swr",
3
- "version": "0.7.2",
3
+ "version": "0.8.2",
4
4
  "description": "A GraphQL code generator plug-in that automatically generates utility functions for SWR.",
5
5
  "main": "build/main/index.js",
6
6
  "typings": "build/main/index.d.ts",
@@ -33,13 +33,13 @@
33
33
  "watch:build": "tsc -p tsconfig.json -w"
34
34
  },
35
35
  "peerDependencies": {
36
- "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"
36
+ "graphql": "<17.0.0"
37
37
  },
38
38
  "dependencies": {
39
- "@graphql-codegen/plugin-helpers": "^2.0.0",
40
- "@graphql-codegen/visitor-plugin-common": "^2.0.0",
39
+ "@graphql-codegen/plugin-helpers": "^2.3.1",
40
+ "@graphql-codegen/visitor-plugin-common": "^2.5.1",
41
41
  "@types/micromatch": "^4.0.1",
42
- "graphql-request": "^3.4.0",
42
+ "graphql-request": "^4.0.0",
43
43
  "micromatch": "^4.0.4",
44
44
  "pascal-case": "^3.1.2",
45
45
  "swr": "^1.0.0",
@@ -50,7 +50,7 @@
50
50
  "@graphql-codegen/typescript": "^2.0.0",
51
51
  "@graphql-codegen/typescript-graphql-request": "^4.0.0",
52
52
  "@graphql-codegen/typescript-operations": "^2.0.0",
53
- "@types/jest": "^27.0.0",
53
+ "@types/jest": "^28.0.0",
54
54
  "@types/node": "^16.0.0",
55
55
  "@typescript-eslint/eslint-plugin": "^5.0.0",
56
56
  "@typescript-eslint/parser": "^5.4.0",
@@ -63,14 +63,14 @@
63
63
  "eslint-plugin-jsx-a11y": "^6.4.1",
64
64
  "eslint-plugin-react": "^7.23.2",
65
65
  "eslint-plugin-react-hooks": "^4.2.0",
66
- "graphql": "^15.5.0 <16.0.0",
67
- "jest": "^27.0.6",
68
- "jest-docblock": "^27.0.6",
69
- "jest-junit": "^13.0.0",
66
+ "graphql": "<17.0.0",
67
+ "jest": "^28.0.0",
68
+ "jest-docblock": "^28.0.0",
69
+ "jest-junit": "^14.0.0",
70
70
  "npm-run-all": "^4.1.5",
71
71
  "prettier": "^2.2.1",
72
72
  "react": "^17.0.2",
73
- "ts-jest": "^27.0.5",
73
+ "ts-jest": "^28.0.0",
74
74
  "typescript": "^4.1.3"
75
75
  },
76
76
  "files": [
package/src/index.ts CHANGED
@@ -4,15 +4,10 @@ import {
4
4
  Types,
5
5
  PluginValidateFn,
6
6
  PluginFunction,
7
+ oldVisit,
7
8
  } from '@graphql-codegen/plugin-helpers'
8
9
  import { LoadedFragment } from '@graphql-codegen/visitor-plugin-common'
9
- import {
10
- visit,
11
- GraphQLSchema,
12
- concatAST,
13
- Kind,
14
- FragmentDefinitionNode,
15
- } from 'graphql'
10
+ import { GraphQLSchema, concatAST, Kind, FragmentDefinitionNode } from 'graphql'
16
11
 
17
12
  import { RawSWRPluginConfig } from './config'
18
13
  import { SWRVisitor } from './visitor'
@@ -38,7 +33,7 @@ export const plugin: PluginFunction<RawSWRPluginConfig> = (
38
33
  ]
39
34
 
40
35
  const visitor = new SWRVisitor(schema, allFragments, config)
41
- visit(allAst, { leave: visitor })
36
+ oldVisit(allAst, { leave: visitor })
42
37
  return {
43
38
  prepend: visitor.getImports(),
44
39
  content: visitor.sdkContent,
package/src/visitor.ts CHANGED
@@ -219,8 +219,10 @@ export class SWRVisitor extends ClientSideBaseVisitor<
219
219
  if (this._enabledInfinite) {
220
220
  codes.push(` const utilsForInfinite = {
221
221
  generateGetKey: <Data = unknown, Variables = unknown>(
222
- id: string,
223
- getKey: ${config.typesPrefix}SWRInfiniteKeyLoader${config.typesSuffix}<Data, Variables>
222
+ id: ${config.autogenSWRKey ? 'SWRKeyInterface' : 'string'},
223
+ getKey: ${config.typesPrefix}SWRInfiniteKeyLoader${
224
+ config.typesSuffix
225
+ }<Data, Variables>
224
226
  ) => (pageIndex: number, previousData: Data | null) => {
225
227
  const key = getKey(pageIndex, previousData)
226
228
  return key ? [id, ...key] : null
@@ -2,7 +2,7 @@ export function getSdkWithHooks(client: GraphQLClient, withWrapper: SdkFunctionW
2
2
  const sdk = getSdk(client, withWrapper);
3
3
  const utilsForInfinite = {
4
4
  generateGetKey: <Data = unknown, Variables = unknown>(
5
- id: string,
5
+ id: SWRKeyInterface,
6
6
  getKey: SWRInfiniteKeyLoader<Data, Variables>
7
7
  ) => (pageIndex: number, previousData: Data | null) => {
8
8
  const key = getKey(pageIndex, previousData)