Skip to content

Commit 905777f

Browse files
author
Tonye Jack
committed
Updated the test setup.
1 parent 5a32977 commit 905777f

File tree

8 files changed

+5617
-172
lines changed

8 files changed

+5617
-172
lines changed

bin/graphql-codegen-hook.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const argv = require('yargs')
2525
)
2626
.command(
2727
'$0 [filenames..]',
28-
'Runs graphql-codegen based on changes to ts/js(x) files',
28+
'Runs graphql-codegen based on changes to .(ts/js(x)|graphql) files',
2929
)
3030
.help()
3131
.argv;
3232

3333
const { filenames = [], verbose = false } = argv;
3434
const fileMatches = filenames.filter(
35-
minimatch.filter("*.+(tsx|jsx|js|ts)", { matchBase: false }),
35+
minimatch.filter("*.+(tsx|jsx|js|ts|graphql)", { matchBase: true }),
3636
);
3737
const shouldExecute = fileMatches.length > 0;
3838

package-lock.json

Lines changed: 5481 additions & 145 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@
1919
"url": "https://github.com/jackton1/graphql-codegen-hook/issues"
2020
},
2121
"homepage": "https://github.com/jackton1/graphql-codegen-hook#readme",
22+
"devDependencies": {
23+
"@graphql-codegen/add": "^1.9.1",
24+
"@graphql-codegen/cli": "^1.9.1",
25+
"@graphql-codegen/typescript": "^1.9.1",
26+
"@graphql-codegen/typescript-operations": "^1.9.1",
27+
"@graphql-codegen/typescript-react-apollo": "^1.9.1",
28+
"graphql": "^14.5.8",
29+
"graphql-tag": "^2.10.1",
30+
"@types/react": "^16.9.17",
31+
"typescript": "^3.7.4",
32+
"react": "^16.9.17",
33+
"@apollo/react-hoc": "^3.1.3",
34+
"@apollo/react-components": "^3.1.3",
35+
"@apollo/react-hooks": "^3.1.3",
36+
"@apollo/react-common": "^3.1.3",
37+
"apollo-client": "^2.6.8",
38+
"apollo-cache": "^1.3.4",
39+
"react-dom": "^16.12.0"
40+
},
2241
"dependencies": {
2342
"path": "^0.12.7",
2443
"process": "^0.11.10",

tests/codegen.yml

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
overwrite: true
2-
schema: "http://localhost:8000/graphql-codegen/"
3-
documents: "src/**/*.graphql"
2+
schema:
3+
- "
4+
type IsUpdatingType {
5+
isUpdating: Boolean!
6+
}
7+
8+
type Query {
9+
isUpdating: Boolean!
10+
}
11+
"
12+
documents: "src/**/*.ts"
413
generates:
5-
src/generated/graphql.ts:
14+
src/generated/graphql.tsx:
615
plugins:
7-
- "typescript"
8-
- "typescript-operations"
9-
- "typescript-react-apollo"
10-
./graphql.schema.json:
11-
plugins:
12-
- "introspection"
16+
- add: /* eslint-disable */
17+
- add: /* tslint:disable */
18+
- typescript
19+
- typescript-operations
20+
- typescript-react-apollo
21+
config:
22+
withHooks: true
23+
noComponents: true

tests/package-lock.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/package.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/src/generated/graphql.tsx

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/* eslint-disable */
2+
/* tslint:disable */
3+
import gql from 'graphql-tag';
4+
import * as React from 'react';
5+
import * as ApolloReactCommon from '@apollo/react-common';
6+
import * as ApolloReactComponents from '@apollo/react-components';
7+
import * as ApolloReactHoc from '@apollo/react-hoc';
8+
import * as ApolloReactHooks from '@apollo/react-hooks';
9+
export type Maybe<T> = T | null;
10+
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
11+
12+
13+
/** All built-in and custom scalars, mapped to their actual values */
14+
export type Scalars = {
15+
ID: string,
16+
String: string,
17+
Boolean: boolean,
18+
Int: number,
19+
Float: number,
20+
};
21+
22+
export type IsUpdatingType = {
23+
__typename?: 'IsUpdatingType',
24+
isUpdating: Scalars['Boolean'],
25+
};
26+
27+
export type Query = {
28+
__typename?: 'Query',
29+
isUpdating: Scalars['Boolean'],
30+
};
31+
32+
export type IsUpdatingQueryVariables = {};
33+
34+
35+
export type IsUpdatingQuery = (
36+
{ __typename?: 'Query' }
37+
& Pick<Query, 'isUpdating'>
38+
);
39+
40+
41+
export const IsUpdatingDocument = gql`
42+
query isUpdating {
43+
isUpdating @client
44+
}
45+
`;
46+
export type IsUpdatingComponentProps = Omit<ApolloReactComponents.QueryComponentOptions<IsUpdatingQuery, IsUpdatingQueryVariables>, 'query'>;
47+
48+
export const IsUpdatingComponent = (props: IsUpdatingComponentProps) => (
49+
<ApolloReactComponents.Query<IsUpdatingQuery, IsUpdatingQueryVariables> query={IsUpdatingDocument} {...props} />
50+
);
51+
52+
export type IsUpdatingProps<TChildProps = {}> = ApolloReactHoc.DataProps<IsUpdatingQuery, IsUpdatingQueryVariables> | TChildProps;
53+
export function withIsUpdating<TProps, TChildProps = {}>(operationOptions?: ApolloReactHoc.OperationOption<
54+
TProps,
55+
IsUpdatingQuery,
56+
IsUpdatingQueryVariables,
57+
IsUpdatingProps<TChildProps>>) {
58+
return ApolloReactHoc.withQuery<TProps, IsUpdatingQuery, IsUpdatingQueryVariables, IsUpdatingProps<TChildProps>>(IsUpdatingDocument, {
59+
alias: 'isUpdating',
60+
...operationOptions
61+
});
62+
};
63+
64+
/**
65+
* __useIsUpdatingQuery__
66+
*
67+
* To run a query within a React component, call `useIsUpdatingQuery` and pass it any options that fit your needs.
68+
* When your component renders, `useIsUpdatingQuery` returns an object from Apollo Client that contains loading, error, and data properties
69+
* you can use to render your UI.
70+
*
71+
* @param baseOptions options that will be passed into the query, supported options are listed on: https://www.apollographql.com/docs/react/api/react-hooks/#options;
72+
*
73+
* @example
74+
* const { data, loading, error } = useIsUpdatingQuery({
75+
* variables: {
76+
* },
77+
* });
78+
*/
79+
export function useIsUpdatingQuery(baseOptions?: ApolloReactHooks.QueryHookOptions<IsUpdatingQuery, IsUpdatingQueryVariables>) {
80+
return ApolloReactHooks.useQuery<IsUpdatingQuery, IsUpdatingQueryVariables>(IsUpdatingDocument, baseOptions);
81+
}
82+
export function useIsUpdatingLazyQuery(baseOptions?: ApolloReactHooks.LazyQueryHookOptions<IsUpdatingQuery, IsUpdatingQueryVariables>) {
83+
return ApolloReactHooks.useLazyQuery<IsUpdatingQuery, IsUpdatingQueryVariables>(IsUpdatingDocument, baseOptions);
84+
}
85+
export type IsUpdatingQueryHookResult = ReturnType<typeof useIsUpdatingQuery>;
86+
export type IsUpdatingLazyQueryHookResult = ReturnType<typeof useIsUpdatingLazyQuery>;
87+
export type IsUpdatingQueryResult = ApolloReactCommon.QueryResult<IsUpdatingQuery, IsUpdatingQueryVariables>;

tests/src/query.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import gql from 'graphql-tag';
2+
3+
// eslint-disable-next-line import/prefer-default-export
4+
export const IS_UPDATING = gql`
5+
query isUpdating {
6+
isUpdating @client
7+
}
8+
`;

0 commit comments

Comments
 (0)