graphql-codegen-plugin-typescript-swr 0.8.4 → 0.8.6
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/README.md +5 -0
- package/build/main/config.d.ts +27 -0
- package/build/main/config.js +3 -0
- package/build/main/index.d.ts +6 -0
- package/build/main/index.js +35 -0
- package/build/main/visitor.d.ts +30 -0
- package/build/main/visitor.js +160 -0
- package/build/module/config.d.ts +27 -0
- package/build/module/config.js +2 -0
- package/build/module/index.d.ts +6 -0
- package/build/module/index.js +30 -0
- package/build/module/visitor.d.ts +30 -0
- package/build/module/visitor.js +153 -0
- package/package.json +5 -2
- package/.editorconfig +0 -13
- package/.eslintrc.js +0 -63
- package/.github/CONTRIBUTING.md +0 -3
- package/.github/ISSUE_TEMPLATE.md +0 -9
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -7
- package/.github/workflows/main.yml +0 -28
- package/.gitignore +0 -8
- package/.prettierignore +0 -3
- package/.prettierrc.json +0 -4
- package/.vscode/extensions.json +0 -8
- package/.vscode/launch.json +0 -29
- package/.vscode/settings.json +0 -41
- package/dev-test/.env +0 -1
- package/dev-test/codegen.yml +0 -357
- package/dev-test/githunt/__generated__/comment-added.subscription.stencil-component.tsx +0 -47
- package/dev-test/githunt/__generated__/comment.query.stencil-component.tsx +0 -68
- package/dev-test/githunt/__generated__/comments-page-comment.fragment.stencil-component.tsx +0 -20
- package/dev-test/githunt/__generated__/current-user.query.stencil-component.tsx +0 -34
- package/dev-test/githunt/__generated__/feed-entry.fragment.stencil-component.tsx +0 -30
- package/dev-test/githunt/__generated__/feed.query.stencil-component.tsx +0 -40
- package/dev-test/githunt/__generated__/new-entry.mutation.stencil-component.tsx +0 -35
- package/dev-test/githunt/__generated__/repo-info.fragment.stencil-component.tsx +0 -26
- package/dev-test/githunt/__generated__/submit-comment.mutation.stencil-component.tsx +0 -35
- package/dev-test/githunt/__generated__/vote-buttons.fragment.stencil-component.tsx +0 -16
- package/dev-test/githunt/__generated__/vote.mutation.stencil-component.tsx +0 -41
- package/dev-test/githunt/comment-added.subscription.graphql +0 -11
- package/dev-test/githunt/comment.query.graphql +0 -33
- package/dev-test/githunt/comments-page-comment.fragment.graphql +0 -9
- package/dev-test/githunt/current-user.query.graphql +0 -6
- package/dev-test/githunt/feed-entry.fragment.graphql +0 -13
- package/dev-test/githunt/feed.query.graphql +0 -8
- package/dev-test/githunt/flow.flow.js +0 -367
- package/dev-test/githunt/graphql-declared-modules.d.ts +0 -87
- package/dev-test/githunt/new-entry.mutation.graphql +0 -5
- package/dev-test/githunt/repo-info.fragment.graphql +0 -12
- package/dev-test/githunt/schema.js +0 -3
- package/dev-test/githunt/schema.json +0 -1750
- package/dev-test/githunt/submit-comment.mutation.graphql +0 -5
- package/dev-test/githunt/typed-document-nodes.ts +0 -892
- package/dev-test/githunt/types.apolloAngular.sdk.ts +0 -570
- package/dev-test/githunt/types.apolloAngular.ts +0 -491
- package/dev-test/githunt/types.avoidOptionals.ts +0 -266
- package/dev-test/githunt/types.d.ts +0 -261
- package/dev-test/githunt/types.enumsAsTypes.ts +0 -261
- package/dev-test/githunt/types.flatten.preResolveTypes.ts +0 -289
- package/dev-test/githunt/types.immutableTypes.ts +0 -267
- package/dev-test/githunt/types.preResolveTypes.compatibility.ts +0 -368
- package/dev-test/githunt/types.preResolveTypes.onlyOperationTypes.ts +0 -156
- package/dev-test/githunt/types.preResolveTypes.ts +0 -293
- package/dev-test/githunt/types.reactApollo.customSuffix.tsx +0 -634
- package/dev-test/githunt/types.reactApollo.hooks.tsx +0 -621
- package/dev-test/githunt/types.reactApollo.preResolveTypes.tsx +0 -648
- package/dev-test/githunt/types.reactApollo.tsx +0 -621
- package/dev-test/githunt/types.reactApollo.v2.tsx +0 -635
- package/dev-test/githunt/types.stencilApollo.tsx +0 -484
- package/dev-test/githunt/types.ts +0 -266
- package/dev-test/githunt/types.urql.tsx +0 -444
- package/dev-test/githunt/types.vueApollo.ts +0 -647
- package/dev-test/githunt/vote-buttons.fragment.graphql +0 -6
- package/dev-test/githunt/vote.mutation.graphql +0 -9
- package/dev-test/setup.js +0 -3
- package/dev-test/test-message/documents.ts +0 -46
- package/dev-test/test-message/schema.graphql +0 -23
- package/dev-test/test-message/types.tsx +0 -237
- package/dev-test/test-schema/env.types.ts +0 -35
- package/dev-test/test-schema/flow-types.flow.js +0 -139
- package/dev-test/test-schema/local/schema-ast.js +0 -2
- package/dev-test/test-schema/local/schema-formats.js +0 -20
- package/dev-test/test-schema/local/schema-object.js +0 -2
- package/dev-test/test-schema/local/schema-text.js +0 -2
- package/dev-test/test-schema/local/schema.graphql +0 -8
- package/dev-test/test-schema/resolvers-federation.ts +0 -233
- package/dev-test/test-schema/resolvers-root.ts +0 -178
- package/dev-test/test-schema/resolvers-types.ts +0 -168
- package/dev-test/test-schema/schema-ast.js +0 -2
- package/dev-test/test-schema/schema-federation.graphql +0 -30
- package/dev-test/test-schema/schema-formats.js +0 -38
- package/dev-test/test-schema/schema-json.js +0 -2
- package/dev-test/test-schema/schema-object.js +0 -2
- package/dev-test/test-schema/schema-text.js +0 -2
- package/dev-test/test-schema/schema-with-imports.graphql +0 -9
- package/dev-test/test-schema/schema-with-root.graphql +0 -22
- package/dev-test/test-schema/schema.graphql +0 -19
- package/dev-test/test-schema/schema.json +0 -1070
- package/dev-test/test-schema/types.preResolveTypes.onlyOperationTypes.ts +0 -19
- package/dev-test/test-schema/types.preResolveTypes.ts +0 -44
- package/dev-test/test-schema/typings.avoidOptionals.ts +0 -27
- package/dev-test/test-schema/typings.enum.ts +0 -19
- package/dev-test/test-schema/typings.immutableTypes.ts +0 -27
- package/dev-test/test-schema/typings.ts +0 -156
- package/dev-test/test-schema/typings.wrapped.ts +0 -29
- package/dev-test/tsconfig.json +0 -18
- package/jest.config.js +0 -30
- package/renovate.json +0 -2
- package/src/config.ts +0 -29
- package/src/index.ts +0 -54
- package/src/visitor.ts +0 -259
- package/tests/outputs/autogenSWRKey.ts +0 -46
- package/tests/outputs/excludeQueries.ts +0 -13
- package/tests/outputs/infinite.ts +0 -49
- package/tests/outputs/mutations.ts +0 -19
- package/tests/outputs/rawRequest.ts +0 -19
- package/tests/outputs/straight.ts +0 -19
- package/tests/swr.spec.ts +0 -306
- package/tests/visitor.spec.ts +0 -19
- package/tsconfig.json +0 -32
- package/tsconfig.main.json +0 -11
- package/tsconfig.module.json +0 -13
- package/yarn-error.log +0 -5477
- package/yarn.lock +0 -5359
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Maybe<T> = T | null;
|
|
2
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
3
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
4
|
-
export type Scalars = {
|
|
5
|
-
ID: string;
|
|
6
|
-
String: string;
|
|
7
|
-
Boolean: boolean;
|
|
8
|
-
Int: number;
|
|
9
|
-
Float: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type TestQueryVariables = Exact<{ [key: string]: never }>;
|
|
13
|
-
|
|
14
|
-
export type TestQuery = {
|
|
15
|
-
__typename?: 'Query';
|
|
16
|
-
testArr1?: Maybe<Array<Maybe<string>>>;
|
|
17
|
-
testArr2: Array<Maybe<string>>;
|
|
18
|
-
testArr3: Array<string>;
|
|
19
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export type Maybe<T> = T | null;
|
|
2
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
3
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
4
|
-
export type Scalars = {
|
|
5
|
-
ID: string;
|
|
6
|
-
String: string;
|
|
7
|
-
Boolean: boolean;
|
|
8
|
-
Int: number;
|
|
9
|
-
Float: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type User = {
|
|
13
|
-
__typename?: 'User';
|
|
14
|
-
id: Scalars['Int'];
|
|
15
|
-
name: Scalars['String'];
|
|
16
|
-
email: Scalars['String'];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type Query = {
|
|
20
|
-
__typename?: 'Query';
|
|
21
|
-
allUsers: Array<Maybe<User>>;
|
|
22
|
-
userById?: Maybe<User>;
|
|
23
|
-
/**
|
|
24
|
-
* Generates a new answer for th
|
|
25
|
-
* guessing game
|
|
26
|
-
*/
|
|
27
|
-
answer: Array<Scalars['Int']>;
|
|
28
|
-
testArr1?: Maybe<Array<Maybe<Scalars['String']>>>;
|
|
29
|
-
testArr2: Array<Maybe<Scalars['String']>>;
|
|
30
|
-
testArr3: Array<Scalars['String']>;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type QueryUserByIdArgs = {
|
|
34
|
-
id: Scalars['Int'];
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type TestQueryVariables = Exact<{ [key: string]: never }>;
|
|
38
|
-
|
|
39
|
-
export type TestQuery = {
|
|
40
|
-
__typename?: 'Query';
|
|
41
|
-
testArr1?: Maybe<Array<Maybe<string>>>;
|
|
42
|
-
testArr2: Array<Maybe<string>>;
|
|
43
|
-
testArr3: Array<string>;
|
|
44
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type Maybe<T> = T | null;
|
|
2
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
3
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
4
|
-
export type Scalars = {
|
|
5
|
-
ID: string;
|
|
6
|
-
String: string;
|
|
7
|
-
Boolean: boolean;
|
|
8
|
-
Int: number;
|
|
9
|
-
Float: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type Query = {
|
|
13
|
-
__typename?: 'Query';
|
|
14
|
-
allUsers: Array<Maybe<User>>;
|
|
15
|
-
userById: Maybe<User>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type QueryUserByIdArgs = {
|
|
19
|
-
id: Scalars['Int'];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type User = {
|
|
23
|
-
__typename?: 'User';
|
|
24
|
-
id: Scalars['Int'];
|
|
25
|
-
name: Scalars['String'];
|
|
26
|
-
email: Scalars['String'];
|
|
27
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Maybe<T> = T | null;
|
|
2
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
3
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
4
|
-
export type Scalars = {
|
|
5
|
-
ID: string;
|
|
6
|
-
String: string;
|
|
7
|
-
Boolean: boolean;
|
|
8
|
-
Int: number;
|
|
9
|
-
Float: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type Query = {
|
|
13
|
-
__typename?: 'Query';
|
|
14
|
-
foo?: Maybe<Foo>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export enum Foo {
|
|
18
|
-
Bar = 'QUX',
|
|
19
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type Maybe<T> = T | null;
|
|
2
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
3
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
4
|
-
export type Scalars = {
|
|
5
|
-
ID: string;
|
|
6
|
-
String: string;
|
|
7
|
-
Boolean: boolean;
|
|
8
|
-
Int: number;
|
|
9
|
-
Float: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type Query = {
|
|
13
|
-
__typename?: 'Query';
|
|
14
|
-
allUsers: Array<Maybe<User>>;
|
|
15
|
-
userById?: Maybe<User>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type QueryUserByIdArgs = {
|
|
19
|
-
id: Scalars['Int'];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type User = {
|
|
23
|
-
__typename?: 'User';
|
|
24
|
-
id: Scalars['Int'];
|
|
25
|
-
name: Scalars['String'];
|
|
26
|
-
email: Scalars['String'];
|
|
27
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { GraphQLResolveInfo } from 'graphql';
|
|
2
|
-
export type Maybe<T> = T | null;
|
|
3
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
4
|
-
export type RequireFields<T, K extends keyof T> = { [X in Exclude<keyof T, K>]?: T[X] } &
|
|
5
|
-
{ [P in K]-?: NonNullable<T[P]> };
|
|
6
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
7
|
-
export type Scalars = {
|
|
8
|
-
ID: string;
|
|
9
|
-
String: string;
|
|
10
|
-
Boolean: boolean;
|
|
11
|
-
Int: number;
|
|
12
|
-
Float: number;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type Query = {
|
|
16
|
-
__typename?: 'Query';
|
|
17
|
-
allUsers: Array<Maybe<User>>;
|
|
18
|
-
userById?: Maybe<User>;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type QueryUserByIdArgs = {
|
|
22
|
-
id: Scalars['Int'];
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type User = {
|
|
26
|
-
__typename?: 'User';
|
|
27
|
-
id: Scalars['Int'];
|
|
28
|
-
name: Scalars['String'];
|
|
29
|
-
email: Scalars['String'];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type ResolverTypeWrapper<T> = Promise<T> | T;
|
|
33
|
-
|
|
34
|
-
export type LegacyStitchingResolver<TResult, TParent, TContext, TArgs> = {
|
|
35
|
-
fragment: string;
|
|
36
|
-
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type NewStitchingResolver<TResult, TParent, TContext, TArgs> = {
|
|
40
|
-
selectionSet: string;
|
|
41
|
-
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
|
|
42
|
-
};
|
|
43
|
-
export type StitchingResolver<TResult, TParent, TContext, TArgs> =
|
|
44
|
-
| LegacyStitchingResolver<TResult, TParent, TContext, TArgs>
|
|
45
|
-
| NewStitchingResolver<TResult, TParent, TContext, TArgs>;
|
|
46
|
-
export type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> =
|
|
47
|
-
| ResolverFn<TResult, TParent, TContext, TArgs>
|
|
48
|
-
| StitchingResolver<TResult, TParent, TContext, TArgs>;
|
|
49
|
-
|
|
50
|
-
export type ResolverFn<TResult, TParent, TContext, TArgs> = (
|
|
51
|
-
parent: TParent,
|
|
52
|
-
args: TArgs,
|
|
53
|
-
context: TContext,
|
|
54
|
-
info: GraphQLResolveInfo
|
|
55
|
-
) => Promise<TResult> | TResult;
|
|
56
|
-
|
|
57
|
-
export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
|
|
58
|
-
parent: TParent,
|
|
59
|
-
args: TArgs,
|
|
60
|
-
context: TContext,
|
|
61
|
-
info: GraphQLResolveInfo
|
|
62
|
-
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;
|
|
63
|
-
|
|
64
|
-
export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
|
|
65
|
-
parent: TParent,
|
|
66
|
-
args: TArgs,
|
|
67
|
-
context: TContext,
|
|
68
|
-
info: GraphQLResolveInfo
|
|
69
|
-
) => TResult | Promise<TResult>;
|
|
70
|
-
|
|
71
|
-
export interface SubscriptionSubscriberObject<TResult, TKey extends string, TParent, TContext, TArgs> {
|
|
72
|
-
subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>;
|
|
73
|
-
resolve?: SubscriptionResolveFn<TResult, { [key in TKey]: TResult }, TContext, TArgs>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface SubscriptionResolverObject<TResult, TParent, TContext, TArgs> {
|
|
77
|
-
subscribe: SubscriptionSubscribeFn<any, TParent, TContext, TArgs>;
|
|
78
|
-
resolve: SubscriptionResolveFn<TResult, any, TContext, TArgs>;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type SubscriptionObject<TResult, TKey extends string, TParent, TContext, TArgs> =
|
|
82
|
-
| SubscriptionSubscriberObject<TResult, TKey, TParent, TContext, TArgs>
|
|
83
|
-
| SubscriptionResolverObject<TResult, TParent, TContext, TArgs>;
|
|
84
|
-
|
|
85
|
-
export type SubscriptionResolver<TResult, TKey extends string, TParent = {}, TContext = {}, TArgs = {}> =
|
|
86
|
-
| ((...args: any[]) => SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>)
|
|
87
|
-
| SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>;
|
|
88
|
-
|
|
89
|
-
export type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
|
|
90
|
-
parent: TParent,
|
|
91
|
-
context: TContext,
|
|
92
|
-
info: GraphQLResolveInfo
|
|
93
|
-
) => Maybe<TTypes> | Promise<Maybe<TTypes>>;
|
|
94
|
-
|
|
95
|
-
export type IsTypeOfResolverFn<T = {}, TContext = {}> = (
|
|
96
|
-
obj: T,
|
|
97
|
-
context: TContext,
|
|
98
|
-
info: GraphQLResolveInfo
|
|
99
|
-
) => boolean | Promise<boolean>;
|
|
100
|
-
|
|
101
|
-
export type NextResolverFn<T> = () => Promise<T>;
|
|
102
|
-
|
|
103
|
-
export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs = {}> = (
|
|
104
|
-
next: NextResolverFn<TResult>,
|
|
105
|
-
parent: TParent,
|
|
106
|
-
args: TArgs,
|
|
107
|
-
context: TContext,
|
|
108
|
-
info: GraphQLResolveInfo
|
|
109
|
-
) => TResult | Promise<TResult>;
|
|
110
|
-
|
|
111
|
-
/** Mapping between all available schema types and the resolvers types */
|
|
112
|
-
export type ResolversTypes = {
|
|
113
|
-
Query: ResolverTypeWrapper<{}>;
|
|
114
|
-
Int: ResolverTypeWrapper<Scalars['Int']>;
|
|
115
|
-
User: ResolverTypeWrapper<User>;
|
|
116
|
-
String: ResolverTypeWrapper<Scalars['String']>;
|
|
117
|
-
Boolean: ResolverTypeWrapper<Scalars['Boolean']>;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/** Mapping between all available schema types and the resolvers parents */
|
|
121
|
-
export type ResolversParentTypes = {
|
|
122
|
-
Query: {};
|
|
123
|
-
Int: Scalars['Int'];
|
|
124
|
-
User: User;
|
|
125
|
-
String: Scalars['String'];
|
|
126
|
-
Boolean: Scalars['Boolean'];
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
export type QueryResolvers<
|
|
130
|
-
ContextType = any,
|
|
131
|
-
ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']
|
|
132
|
-
> = {
|
|
133
|
-
allUsers?: Resolver<Array<Maybe<ResolversTypes['User']>>, ParentType, ContextType>;
|
|
134
|
-
userById?: Resolver<Maybe<ResolversTypes['User']>, ParentType, ContextType, RequireFields<QueryUserByIdArgs, 'id'>>;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export type UserResolvers<
|
|
138
|
-
ContextType = any,
|
|
139
|
-
ParentType extends ResolversParentTypes['User'] = ResolversParentTypes['User']
|
|
140
|
-
> = {
|
|
141
|
-
id?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
|
|
142
|
-
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
|
143
|
-
email?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
|
|
144
|
-
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
export type Resolvers<ContextType = any> = {
|
|
148
|
-
Query?: QueryResolvers<ContextType>;
|
|
149
|
-
User?: UserResolvers<ContextType>;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @deprecated
|
|
154
|
-
* Use "Resolvers" root object instead. If you wish to get "IResolvers", add "typesPrefix: I" to your config.
|
|
155
|
-
*/
|
|
156
|
-
export type IResolvers<ContextType = any> = Resolvers<ContextType>;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare namespace GraphQL {
|
|
2
|
-
export type Maybe<T> = T | null;
|
|
3
|
-
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
|
|
4
|
-
/** All built-in and custom scalars, mapped to their actual values */
|
|
5
|
-
export type Scalars = {
|
|
6
|
-
ID: string;
|
|
7
|
-
String: string;
|
|
8
|
-
Boolean: boolean;
|
|
9
|
-
Int: number;
|
|
10
|
-
Float: number;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export type Query = {
|
|
14
|
-
__typename?: 'Query';
|
|
15
|
-
allUsers: Array<Maybe<User>>;
|
|
16
|
-
userById?: Maybe<User>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export type QueryUserByIdArgs = {
|
|
20
|
-
id: Scalars['Int'];
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export type User = {
|
|
24
|
-
__typename?: 'User';
|
|
25
|
-
id: Scalars['Int'];
|
|
26
|
-
name: Scalars['String'];
|
|
27
|
-
email: Scalars['String'];
|
|
28
|
-
};
|
|
29
|
-
}
|
package/dev-test/tsconfig.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"esModuleInterop": true,
|
|
4
|
-
"lib": ["esnext"],
|
|
5
|
-
"jsx": "react",
|
|
6
|
-
"jsxFactory": "React.createElement",
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"strict": true,
|
|
9
|
-
"noImplicitAny": true,
|
|
10
|
-
"noImplicitThis": true,
|
|
11
|
-
"alwaysStrict": true,
|
|
12
|
-
"noImplicitReturns": true,
|
|
13
|
-
"noUnusedLocals": true,
|
|
14
|
-
"noUnusedParameters": true,
|
|
15
|
-
"experimentalDecorators": true
|
|
16
|
-
},
|
|
17
|
-
"include": ["**/*.ts", "**/*.tsx"]
|
|
18
|
-
}
|
package/jest.config.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const { resolve } = require('path')
|
|
2
|
-
const { pathsToModuleNameMapper } = require('ts-jest')
|
|
3
|
-
|
|
4
|
-
const pkg = require('./package.json')
|
|
5
|
-
const tsconfig = require('./tsconfig.json')
|
|
6
|
-
const CI = !!process.env.CI
|
|
7
|
-
|
|
8
|
-
module.exports = () => {
|
|
9
|
-
return {
|
|
10
|
-
displayName: pkg.name,
|
|
11
|
-
rootDir: __dirname,
|
|
12
|
-
preset: 'ts-jest',
|
|
13
|
-
testEnvironment: 'node',
|
|
14
|
-
restoreMocks: true,
|
|
15
|
-
reporters: ['default'],
|
|
16
|
-
modulePathIgnorePatterns: ['dist'],
|
|
17
|
-
moduleNameMapper: pathsToModuleNameMapper(
|
|
18
|
-
tsconfig.compilerOptions.paths || [],
|
|
19
|
-
{
|
|
20
|
-
prefix: `./`,
|
|
21
|
-
}
|
|
22
|
-
),
|
|
23
|
-
cacheDirectory: resolve(
|
|
24
|
-
__dirname,
|
|
25
|
-
`${CI ? '' : 'node_modules/'}.cache/jest`
|
|
26
|
-
),
|
|
27
|
-
setupFiles: [`${__dirname}/dev-test/setup.js`],
|
|
28
|
-
collectCoverage: false,
|
|
29
|
-
}
|
|
30
|
-
}
|
package/renovate.json
DELETED
package/src/config.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { RawClientSideBasePluginConfig } from '@graphql-codegen/visitor-plugin-common'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @description This plugin generates [`graphql-request`](https://www.npmjs.com/package/graphql-request) ready-to-use SDK, which is fully-typed.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export interface RawSWRPluginConfig extends RawClientSideBasePluginConfig {
|
|
8
|
-
/**
|
|
9
|
-
* @description By default the `request` method return the `data` or `errors` key from the response. If you need to access the `extensions` key you can use the `rawRequest` method.
|
|
10
|
-
* @default false
|
|
11
|
-
*
|
|
12
|
-
* @exampleMarkdown
|
|
13
|
-
* ```yml
|
|
14
|
-
* generates:
|
|
15
|
-
* path/to/file.ts:
|
|
16
|
-
* plugins:
|
|
17
|
-
* - typescript
|
|
18
|
-
* - typescript-operations
|
|
19
|
-
* - typescript-graphql-request
|
|
20
|
-
* - graphql-codegen-plugin-typescript-swr
|
|
21
|
-
* config:
|
|
22
|
-
* rawRequest: true
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
rawRequest?: boolean
|
|
26
|
-
excludeQueries?: string | string[]
|
|
27
|
-
useSWRInfinite?: string | string[]
|
|
28
|
-
autogenSWRKey?: boolean
|
|
29
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { extname } from 'path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Types,
|
|
5
|
-
PluginValidateFn,
|
|
6
|
-
PluginFunction,
|
|
7
|
-
oldVisit,
|
|
8
|
-
} from '@graphql-codegen/plugin-helpers'
|
|
9
|
-
import { LoadedFragment } from '@graphql-codegen/visitor-plugin-common'
|
|
10
|
-
import { GraphQLSchema, concatAST, Kind, FragmentDefinitionNode } from 'graphql'
|
|
11
|
-
|
|
12
|
-
import { RawSWRPluginConfig } from './config'
|
|
13
|
-
import { SWRVisitor } from './visitor'
|
|
14
|
-
|
|
15
|
-
export const plugin: PluginFunction<RawSWRPluginConfig> = (
|
|
16
|
-
schema: GraphQLSchema,
|
|
17
|
-
documents: Types.DocumentFile[],
|
|
18
|
-
config: RawSWRPluginConfig
|
|
19
|
-
) => {
|
|
20
|
-
const allAst = concatAST(documents.map((v) => v.document))
|
|
21
|
-
|
|
22
|
-
const allFragments: LoadedFragment[] = [
|
|
23
|
-
// prettier-ignore
|
|
24
|
-
...(allAst.definitions.filter(
|
|
25
|
-
(d) => d.kind === Kind.FRAGMENT_DEFINITION
|
|
26
|
-
) as FragmentDefinitionNode[]).map((fragmentDef) => ({
|
|
27
|
-
node: fragmentDef,
|
|
28
|
-
name: fragmentDef.name.value,
|
|
29
|
-
onType: fragmentDef.typeCondition.name.value,
|
|
30
|
-
isExternal: false,
|
|
31
|
-
})),
|
|
32
|
-
...(config.externalFragments || []),
|
|
33
|
-
]
|
|
34
|
-
|
|
35
|
-
const visitor = new SWRVisitor(schema, allFragments, config)
|
|
36
|
-
oldVisit(allAst, { leave: visitor })
|
|
37
|
-
return {
|
|
38
|
-
prepend: visitor.getImports(),
|
|
39
|
-
content: visitor.sdkContent,
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const validate: PluginValidateFn<any> = async (
|
|
44
|
-
_schema: GraphQLSchema,
|
|
45
|
-
_documents: Types.DocumentFile[],
|
|
46
|
-
_config: RawSWRPluginConfig,
|
|
47
|
-
outputFile: string
|
|
48
|
-
) => {
|
|
49
|
-
if (extname(outputFile) !== '.ts') {
|
|
50
|
-
throw new Error(`Plugin "typescript-swr" requires extension to be ".ts"!`)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { SWRVisitor }
|