Skip to content

Commit

Permalink
Merge pull request #11 from gabrielcsapo/gcsapo/prettier
Browse files Browse the repository at this point in the history
chore: sets up lint-staged and runs prettier
  • Loading branch information
asakusuma committed Mar 28, 2023
2 parents 3e57a6b + 2de96e1 commit 13df6df
Show file tree
Hide file tree
Showing 33 changed files with 1,284 additions and 466 deletions.
11 changes: 9 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,12 @@
}
}
],
"ignorePatterns": ["dist", "node_modules", "dev-test", "website", "test-files", "examples/front-end"]
}
"ignorePatterns": [
"dist",
"node_modules",
"dev-test",
"website",
"test-files",
"examples/front-end"
]
}
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches:
- main
- 'v*' # older version branches
- "v*" # older version branches
tags:
- '*'
- "*"
pull_request: {}

jobs:
Expand All @@ -16,16 +16,16 @@ jobs:

strategy:
matrix:
node-version: ['^14.10', '16', '18']
node-version: ["^14.10", "16", "18"]

steps:
- uses: actions/checkout@v3
- uses: volta-cli/action@v3
with:
node-version: ${{ matrix.node-version }}
- name: install dependencies
run: yarn
- name: lint
run: yarn lint
- name: test
run: yarn test
- uses: actions/checkout@v3
- uses: volta-cli/action@v3
with:
node-version: ${{ matrix.node-version }}
- name: install dependencies
run: yarn
- name: lint
run: yarn lint
- name: test
run: yarn test
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

./node_modules/.bin/lint-staged
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

## 0.0.1

Initial commit, forked from: https://github.com/dotansimha/graphql-code-generator/tree/master/packages/plugins/typescript/typed-document-node
Initial commit, forked from: https://github.com/dotansimha/graphql-code-generator/tree/master/packages/plugins/typescript/typed-document-node
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ The point of this fork is to add the ability to specify a `fragmentImportsSource
```

See the tests for behavior:
https://github.com/asa-graphql-codegen/asa-graphql-ts-typed-document/blob/069cac5881fafa7f043d4e9a558344e887ac49ee/tests/typed-document-node.spec.ts#L149
https://github.com/asa-graphql-codegen/asa-graphql-ts-typed-document/blob/069cac5881fafa7f043d4e9a558344e887ac49ee/tests/typed-document-node.spec.ts#L149
11 changes: 7 additions & 4 deletions babel.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: process.versions.node.split('.')[0] } }],
'@babel/preset-typescript',
presets: [
[
"@babel/preset-env",
{ targets: { node: process.versions.node.split(".")[0] } },
],
};
"@babel/preset-typescript",
],
};
6 changes: 3 additions & 3 deletions dev-test/setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
process.on('unhandledRejection', (err) => {
fail(err);
});
process.on("unhandledRejection", (err) => {
fail(err);
});
32 changes: 19 additions & 13 deletions dev-test/test-schema/env.types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type Exact<T extends { [key: string]: unknown }> = {
[K in keyof T]: T[K];
};
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
[SubKey in K]?: Maybe<T[SubKey]>;
};
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
[SubKey in K]: Maybe<T[SubKey]>;
};
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
Expand All @@ -13,26 +19,26 @@ export type Scalars = {
};

export type Query = {
__typename?: 'Query';
__typename?: "Query";
allUsers: Array<Maybe<User>>;
/**
* Generates a new answer for th
* guessing game
*/
answer: Array<Scalars['Int']>;
testArr1?: Maybe<Array<Maybe<Scalars['String']>>>;
testArr2: Array<Maybe<Scalars['String']>>;
testArr3: Array<Scalars['String']>;
answer: Array<Scalars["Int"]>;
testArr1?: Maybe<Array<Maybe<Scalars["String"]>>>;
testArr2: Array<Maybe<Scalars["String"]>>;
testArr3: Array<Scalars["String"]>;
userById?: Maybe<User>;
};

export type QueryUserByIdArgs = {
id: Scalars['Int'];
id: Scalars["Int"];
};

export type User = {
__typename?: 'User';
email: Scalars['String'];
id: Scalars['Int'];
name: Scalars['String'];
__typename?: "User";
email: Scalars["String"];
id: Scalars["Int"];
name: Scalars["String"];
};
99 changes: 73 additions & 26 deletions dev-test/test-schema/flow-types.flow.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import { type GraphQLResolveInfo } from 'graphql';
import { type GraphQLResolveInfo } from "graphql";
export type $RequireFields<Origin, Keys> = $Diff<Origin, Keys> &
$ObjMapi<Keys, <Key>(k: Key) => $NonMaybeType<$ElementType<Origin, Key>>>;
/** All built-in and custom scalars, mapped to their actual values */
Expand All @@ -13,20 +13,20 @@ export type Scalars = {|
|};

export type Query = {|
__typename?: 'Query',
__typename?: "Query",
allUsers: Array<?User>,
userById?: ?User,
|};

export type QueryUserByIdArgs = {|
id: $ElementType<Scalars, 'Int'>,
id: $ElementType<Scalars, "Int">,
|};

export type User = {|
__typename?: 'User',
email: $ElementType<Scalars, 'String'>,
id: $ElementType<Scalars, 'Int'>,
name: $ElementType<Scalars, 'String'>,
__typename?: "User",
email: $ElementType<Scalars, "String">,
id: $ElementType<Scalars, "Int">,
name: $ElementType<Scalars, "String">,
|};

export type Resolver<Result, Parent = {}, Context = {}, Args = {}> = (
Expand All @@ -50,9 +50,25 @@ export type SubscriptionResolveFn<Result, Parent, Context, Args> = (
info: GraphQLResolveInfo
) => Result | Promise<Result>;

export interface SubscriptionSubscriberObject<Result, Key: string, Parent, Context, Args> {
subscribe: SubscriptionSubscribeFn<{ [key: Key]: Result }, Parent, Context, Args>;
resolve?: SubscriptionResolveFn<Result, { [key: Key]: Result }, Context, Args>;
export interface SubscriptionSubscriberObject<
Result,
Key: string,
Parent,
Context,
Args
> {
subscribe: SubscriptionSubscribeFn<
{ [key: Key]: Result },
Parent,
Context,
Args
>;
resolve?: SubscriptionResolveFn<
Result,
{ [key: Key]: Result },
Context,
Args
>;
}

export interface SubscriptionResolverObject<Result, Parent, Context, Args> {
Expand All @@ -64,8 +80,16 @@ export type SubscriptionObject<Result, Key: string, Parent, Context, Args> =
| SubscriptionSubscriberObject<Result, Key, Parent, Context, Args>
| SubscriptionResolverObject<Result, Parent, Context, Args>;

export type SubscriptionResolver<Result, Key: string, Parent = {}, Context = {}, Args = {}> =
| ((...args: Array<any>) => SubscriptionObject<Result, Key, Parent, Context, Args>)
export type SubscriptionResolver<
Result,
Key: string,
Parent = {},
Context = {},
Args = {}
> =
| ((
...args: Array<any>
) => SubscriptionObject<Result, Key, Parent, Context, Args>)
| SubscriptionObject<Result, Key, Parent, Context, Args>;

export type TypeResolveFn<Types, Parent = {}, Context = {}> = (
Expand All @@ -82,7 +106,12 @@ export type IsTypeOfResolverFn<T = {}, Context = {}> = (

export type NextResolverFn<T> = () => Promise<T>;

export type DirectiveResolverFn<Result = {}, Parent = {}, Args = {}, Context = {}> = (
export type DirectiveResolverFn<
Result = {},
Parent = {},
Args = {},
Context = {}
> = (
next: NextResolverFn<Result>,
parent: Parent,
args: Args,
Expand All @@ -94,36 +123,54 @@ export type ResolverTypeWrapper<T> = Promise<T> | T;

/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = {
Boolean: ResolverTypeWrapper<$ElementType<Scalars, 'Boolean'>>,
Int: ResolverTypeWrapper<$ElementType<Scalars, 'Int'>>,
Boolean: ResolverTypeWrapper<$ElementType<Scalars, "Boolean">>,
Int: ResolverTypeWrapper<$ElementType<Scalars, "Int">>,
Query: ResolverTypeWrapper<{}>,
String: ResolverTypeWrapper<$ElementType<Scalars, 'String'>>,
String: ResolverTypeWrapper<$ElementType<Scalars, "String">>,
User: ResolverTypeWrapper<User>,
};

/** Mapping between all available schema types and the resolvers parents */
export type ResolversParentTypes = {
Boolean: $ElementType<Scalars, 'Boolean'>,
Int: $ElementType<Scalars, 'Int'>,
Boolean: $ElementType<Scalars, "Boolean">,
Int: $ElementType<Scalars, "Int">,
Query: {},
String: $ElementType<Scalars, 'String'>,
String: $ElementType<Scalars, "String">,
User: User,
};

export type QueryResolvers<ContextType = any, ParentType = $ElementType<ResolversParentTypes, 'Query'>> = {
allUsers?: Resolver<Array<?$ElementType<ResolversTypes, 'User'>>, ParentType, ContextType>,
export type QueryResolvers<
ContextType = any,
ParentType = $ElementType<ResolversParentTypes, "Query">
> = {
allUsers?: Resolver<
Array<?$ElementType<ResolversTypes, "User">>,
ParentType,
ContextType
>,
userById?: Resolver<
?$ElementType<ResolversTypes, 'User'>,
?$ElementType<ResolversTypes, "User">,
ParentType,
ContextType,
$RequireFields<QueryUserByIdArgs, { id: * }>
>,
};

export type UserResolvers<ContextType = any, ParentType = $ElementType<ResolversParentTypes, 'User'>> = {
email?: Resolver<$ElementType<ResolversTypes, 'String'>, ParentType, ContextType>,
id?: Resolver<$ElementType<ResolversTypes, 'Int'>, ParentType, ContextType>,
name?: Resolver<$ElementType<ResolversTypes, 'String'>, ParentType, ContextType>,
export type UserResolvers<
ContextType = any,
ParentType = $ElementType<ResolversParentTypes, "User">
> = {
email?: Resolver<
$ElementType<ResolversTypes, "String">,
ParentType,
ContextType
>,
id?: Resolver<$ElementType<ResolversTypes, "Int">, ParentType, ContextType>,
name?: Resolver<
$ElementType<ResolversTypes, "String">,
ParentType,
ContextType
>,
__isTypeOf?: IsTypeOfResolverFn<ParentType, ContextType>,
};

Expand Down
2 changes: 1 addition & 1 deletion dev-test/test-schema/local/schema-ast.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const schemaFormats = require('./schema-formats');
const schemaFormats = require("./schema-formats");
module.exports.schema = schemaFormats.schemaAst;
11 changes: 7 additions & 4 deletions dev-test/test-schema/local/schema-formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
* exports all four formats to be used in tests.
*/

const GraphQL = require('graphql');
const fs = require('fs');
const path = require('path');
const schemaText = fs.readFileSync(path.join(__dirname, 'schema.graphql'), 'utf8');
const GraphQL = require("graphql");
const fs = require("fs");
const path = require("path");
const schemaText = fs.readFileSync(
path.join(__dirname, "schema.graphql"),
"utf8"
);
const schemaObject = GraphQL.buildSchema(schemaText);
const schemaAst = GraphQL.parse(schemaText);

Expand Down
2 changes: 1 addition & 1 deletion dev-test/test-schema/local/schema-object.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const schemaFormats = require('./schema-formats');
const schemaFormats = require("./schema-formats");
module.exports.schema = schemaFormats.schemaObject;
2 changes: 1 addition & 1 deletion dev-test/test-schema/local/schema-text.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const schemaFormats = require('./schema-formats');
const schemaFormats = require("./schema-formats");
module.exports.schema = schemaFormats.schemaText;

0 comments on commit 13df6df

Please sign in to comment.