Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Refactor TypeScript plugins #1353

Merged
merged 178 commits into from
Mar 14, 2019
Merged
Changes from 2 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
6b5689e
WIP, move common visitor to separate package, clear flow package, add…
dotansimha Feb 25, 2019
0af742f
fix other flow plugin
dotansimha Feb 25, 2019
0024359
rebase without flow code
dotansimha Feb 25, 2019
812ca81
wip typescript package
dotansimha Feb 25, 2019
fa1ed3d
added validation for ts files
dotansimha Feb 25, 2019
72e83d5
wip
dotansimha Feb 25, 2019
c039ea3
done with basic typescript package
dotansimha Feb 26, 2019
65b7b03
WIP: move all common code from flow-documents.
dotansimha Feb 26, 2019
829e464
all green on typescript-documents and flow-documents
dotansimha Feb 26, 2019
86b0bd7
added tsc compilation to tests
dotansimha Feb 26, 2019
e431c8c
fix for arguments and variables
dotansimha Feb 26, 2019
2d1648b
wip resolvers
dotansimha Feb 27, 2019
4b3858b
implement common resolvers package
dotansimha Feb 28, 2019
af84418
fixed tests for typescript packages
dotansimha Feb 28, 2019
4d387c0
added missing features for typescript plugin
dotansimha Feb 28, 2019
966a535
added missing features
dotansimha Feb 28, 2019
35695be
added immutableTypes to typescript-documents
dotansimha Feb 28, 2019
d806787
fixes
dotansimha Feb 28, 2019
a11748a
update versions
dotansimha Mar 1, 2019
f085605
update lock file
dotansimha Mar 1, 2019
e884404
#1369 Duplicated type when fields are named the same as operation types
kamilkisiela Mar 1, 2019
1cbb746
#1380 Include __typename in fragments and metadata fields
kamilkisiela Mar 1, 2019
8c44d99
#1355 apply typesPrefix to enums in typescript-documents
kamilkisiela Mar 1, 2019
eadbfc9
refactor graphql-codegen-typescript-graphql-files-modules
dotansimha Mar 3, 2019
53b1327
wip
dotansimha Mar 4, 2019
59e566c
WIP
dotansimha Mar 4, 2019
715ea23
wip react-apollo
dotansimha Mar 4, 2019
02a4e93
wip react-apollo
dotansimha Mar 4, 2019
1f03407
fixes for react-apollo
dotansimha Mar 5, 2019
65b6c28
removed old code
dotansimha Mar 5, 2019
eb2446f
removed old example
dotansimha Mar 5, 2019
6d489df
added ts compilation to tests
dotansimha Mar 5, 2019
e5ee2e0
fixes
dotansimha Mar 5, 2019
ae4be8a
done with apollo angular
dotansimha Mar 5, 2019
40838b9
fix ci
dotansimha Mar 5, 2019
ef03340
Add IResolvers & IDirectiveResolvers
ardatan Mar 5, 2019
3c236f8
Fix flow
ardatan Mar 5, 2019
4e88769
#1400 Include used introspection types in based on documents
kamilkisiela Mar 5, 2019
ce418f6
Add Scalars to IResolvers
ardatan Mar 5, 2019
0502039
Fix IDirectiveResolvers
ardatan Mar 5, 2019
7ce6a6f
Naming convention
kamilkisiela Mar 5, 2019
2f6d69d
Apply Naming Convention to flow
kamilkisiela Mar 5, 2019
e619b89
Include objects
kamilkisiela Mar 5, 2019
0f9088f
Fix missing types and enums
kamilkisiela Mar 5, 2019
3b09205
Lazy Dotan
kamilkisiela Mar 5, 2019
0517f4c
Fix kind
kamilkisiela Mar 5, 2019
7293787
Fix tests
ardatan Mar 5, 2019
be0548e
Fix an issue with double prefix
kamilkisiela Mar 5, 2019
5933da9
Fix incorrect test in flow-documents
kamilkisiela Mar 5, 2019
86355be
Fix double i
kamilkisiela Mar 5, 2019
26f3503
Fix DirectiveResolver signature
ardatan Mar 5, 2019
d41b704
fix stupid mistake
kamilkisiela Mar 5, 2019
ba991e7
Fix ts-documents ii issue
kamilkisiela Mar 5, 2019
c608c62
update lockfile
dotansimha Mar 6, 2019
1690e3e
Refactor stencil-apollo
ardatan Mar 6, 2019
6863e55
Merge pull request #1419 from dotansimha/refactor/stencil-apollo
ardatan Mar 6, 2019
dccbd43
Enable tree-shaking
ardatan Mar 6, 2019
a4067f8
Introduce graphql-codegen-testing
ardatan Mar 6, 2019
a00131b
Remove old templates
ardatan Mar 7, 2019
19a5d6b
remove esModuleInterop and use dynamic import instead of require to i…
ardatan Mar 7, 2019
3121e7f
WIP, move common visitor to separate package, clear flow package, add…
dotansimha Feb 25, 2019
ad32bf0
fix other flow plugin
dotansimha Feb 25, 2019
638f68d
rebase without flow code
dotansimha Feb 25, 2019
44b80d7
wip typescript package
dotansimha Feb 25, 2019
72f756b
added validation for ts files
dotansimha Feb 25, 2019
7b62aef
wip
dotansimha Feb 25, 2019
0a97949
done with basic typescript package
dotansimha Feb 26, 2019
a77ccb7
WIP: move all common code from flow-documents.
dotansimha Feb 26, 2019
0b943c1
all green on typescript-documents and flow-documents
dotansimha Feb 26, 2019
d6cf20f
added tsc compilation to tests
dotansimha Feb 26, 2019
04f696e
fix for arguments and variables
dotansimha Feb 26, 2019
3232329
wip resolvers
dotansimha Feb 27, 2019
978d0d2
implement common resolvers package
dotansimha Feb 28, 2019
c87152b
fixed tests for typescript packages
dotansimha Feb 28, 2019
45b2e4e
added missing features for typescript plugin
dotansimha Feb 28, 2019
a326c17
added missing features
dotansimha Feb 28, 2019
2396ace
added immutableTypes to typescript-documents
dotansimha Feb 28, 2019
be0d009
fixes
dotansimha Feb 28, 2019
32bbb7a
update versions
dotansimha Mar 1, 2019
a0f0188
update lock file
dotansimha Mar 1, 2019
28fe025
#1369 Duplicated type when fields are named the same as operation types
kamilkisiela Mar 1, 2019
009665e
#1380 Include __typename in fragments and metadata fields
kamilkisiela Mar 1, 2019
d8a3362
#1355 apply typesPrefix to enums in typescript-documents
kamilkisiela Mar 1, 2019
a520fbc
refactor graphql-codegen-typescript-graphql-files-modules
dotansimha Mar 3, 2019
913de21
wip
dotansimha Mar 4, 2019
29a5c1c
WIP
dotansimha Mar 4, 2019
f2940ff
wip react-apollo
dotansimha Mar 4, 2019
455f536
wip react-apollo
dotansimha Mar 4, 2019
99b312a
fixes for react-apollo
dotansimha Mar 5, 2019
86eaf3e
removed old code
dotansimha Mar 5, 2019
d202f0f
removed old example
dotansimha Mar 5, 2019
d54472b
added ts compilation to tests
dotansimha Mar 5, 2019
95c6010
fixes
dotansimha Mar 5, 2019
927c47b
done with apollo angular
dotansimha Mar 5, 2019
f83c13f
fix ci
dotansimha Mar 5, 2019
1032441
Add IResolvers & IDirectiveResolvers
ardatan Mar 5, 2019
c4eb825
Fix flow
ardatan Mar 5, 2019
076fbf5
#1400 Include used introspection types in based on documents
kamilkisiela Mar 5, 2019
00b25b7
Add Scalars to IResolvers
ardatan Mar 5, 2019
06a8adf
Fix IDirectiveResolvers
ardatan Mar 5, 2019
bdefc7e
Naming convention
kamilkisiela Mar 5, 2019
1551b89
Apply Naming Convention to flow
kamilkisiela Mar 5, 2019
baaa2e4
Include objects
kamilkisiela Mar 5, 2019
e3873d7
Fix missing types and enums
kamilkisiela Mar 5, 2019
776da58
Lazy Dotan
kamilkisiela Mar 5, 2019
2fea7f2
Fix kind
kamilkisiela Mar 5, 2019
adb2f63
Fix tests
ardatan Mar 5, 2019
802255c
Fix an issue with double prefix
kamilkisiela Mar 5, 2019
0da9e35
Fix incorrect test in flow-documents
kamilkisiela Mar 5, 2019
854e358
Fix double i
kamilkisiela Mar 5, 2019
fe7ea6b
Fix DirectiveResolver signature
ardatan Mar 5, 2019
fbf59ce
fix stupid mistake
kamilkisiela Mar 5, 2019
32e9e5b
Fix ts-documents ii issue
kamilkisiela Mar 5, 2019
8c4a495
update lockfile
dotansimha Mar 6, 2019
9a9a205
Make sure bug with useFlowReadOnlyTypes on Enums is fixed #1413
kamilkisiela Mar 6, 2019
67644ee
Refactor stencil-apollo
ardatan Mar 6, 2019
e0a0ea7
wip mongo
dotansimha Mar 11, 2019
3505b21
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
ardatan Mar 11, 2019
28b2921
fix
ardatan Mar 11, 2019
83524b7
Merge branch 'refactor/typescript' into refactor/tree-shaking
ardatan Mar 11, 2019
a6eded5
fixes
dotansimha Mar 11, 2019
05886e4
fixes
ardatan Mar 11, 2019
f78652f
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
ardatan Mar 11, 2019
34e4082
cleanup
dotansimha Mar 11, 2019
6ec94bd
empty commit
dotansimha Mar 11, 2019
c197dd8
fix
dotansimha Mar 11, 2019
88c21dc
gql-gen init
kamilkisiela Mar 11, 2019
eaadb84
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
kamilkisiela Mar 11, 2019
14dc463
fix
ardatan Mar 11, 2019
8cfde08
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
ardatan Mar 11, 2019
5d4e608
Merge branch 'refactor/typescript' into refactor/tree-shaking
ardatan Mar 11, 2019
b8a815c
Merge pull request #1417 from dotansimha/apply/init
dotansimha Mar 11, 2019
0d1c696
remove all pretest scripts
dotansimha Mar 11, 2019
2da4f26
Support schema stitching in typescript-resolvers
kamilkisiela Mar 11, 2019
aee3ac6
Merge pull request #1439 from dotansimha/feat/resolvers-stitching
dotansimha Mar 11, 2019
2d4a70f
Schema Definition Object was printed as object
kamilkisiela Mar 11, 2019
3f859ab
Merge pull request #1441 from dotansimha/fix/schema-definition-as-object
dotansimha Mar 11, 2019
6f654a3
WIP mongo plugin
dotansimha Mar 12, 2019
813c8d3
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
dotansimha Mar 12, 2019
7276237
No core package
kamilkisiela Mar 12, 2019
02a522e
Old stuff
kamilkisiela Mar 12, 2019
82e27c4
comment
kamilkisiela Mar 12, 2019
df8aa0d
Merge pull request #1446 from dotansimha/refactor/no-core
dotansimha Mar 12, 2019
f5d41c9
fix graphql dep conflict for jest
ardatan Mar 12, 2019
b9599e1
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
ardatan Mar 12, 2019
9114d18
Merge branch 'refactor/typescript' into refactor/tree-shaking
ardatan Mar 12, 2019
f7d3368
DONE
ardatan Mar 12, 2019
d823090
Optimize website for lazy-loading
ardatan Mar 12, 2019
3e3181f
Fix custom plugin loading
ardatan Mar 12, 2019
22e1155
Add cjs proxy to flow-operations
ardatan Mar 12, 2019
fdbb791
Update examples
ardatan Mar 12, 2019
2b103fb
Fix Stencil-Apollo demo
ardatan Mar 12, 2019
52db8d2
Use graphql-codegen-testing for mongodb plugin
ardatan Mar 12, 2019
cbaa90b
Merge pull request #1420 from dotansimha/refactor/tree-shaking
dotansimha Mar 13, 2019
df8117c
Merge branch 'master' into refactor/typescript
dotansimha Mar 13, 2019
4551613
fixes
dotansimha Mar 13, 2019
e359e2c
fixes
dotansimha Mar 13, 2019
8a247e2
Docs WIP
kamilkisiela Mar 12, 2019
7c247a8
More docs
kamilkisiela Mar 13, 2019
8e3376c
Repo's readme
kamilkisiela Mar 13, 2019
16bda3d
added tests
dotansimha Mar 14, 2019
8cc09fa
Merge branch 'master' into refactor/typescript
dotansimha Mar 14, 2019
6f29999
Merge pull request #1447 from dotansimha/refactor/docs
dotansimha Mar 14, 2019
825c889
update docs
dotansimha Mar 14, 2019
515e2e1
Generate different bundles instead of esm package (#1460)
ardatan Mar 14, 2019
ddf5d60
cleanup for jest config
dotansimha Mar 14, 2019
411d62e
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
dotansimha Mar 14, 2019
37f8ada
move testing package to utils dir
dotansimha Mar 14, 2019
ec24200
Move part of logic into a separate package (#1458)
kamilkisiela Mar 14, 2019
c22538c
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
dotansimha Mar 14, 2019
c69ca8b
Remove old-templates (#1461)
kamilkisiela Mar 14, 2019
4859306
fixes
dotansimha Mar 14, 2019
d705104
Merge branch 'refactor/typescript' of github.com:dotansimha/graphql-c…
dotansimha Mar 14, 2019
bc19151
remove old changelog file
dotansimha Mar 14, 2019
56111db
Merge branch 'master' into refactor/typescript
dotansimha Mar 14, 2019
e1c06b8
update lockfile
dotansimha Mar 14, 2019
1ce660a
fixes and cleanup
dotansimha Mar 14, 2019
f30ac65
fixes
dotansimha Mar 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/graphql-codegen-cli/package.json
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@
"graphql-config": "2.2.1",
"graphql-import": "0.7.1",
"graphql-tag-pluck": "0.7.0",
"graphql-toolkit": "0.2.4",
"graphql-toolkit": "0.2.0",
"graphql-tools": "4.0.4",
"indent-string": "3.2.0",
"inquirer": "6.2.2",
2 changes: 1 addition & 1 deletion packages/graphql-codegen-core/package.json
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@
"change-case": "3.1.0",
"common-tags": "1.8.0",
"graphql-tag": "2.10.1",
"graphql-toolkit": "0.2.4",
"graphql-toolkit": "0.2.0",
"graphql-tools": "4.0.4",
"ts-log": "2.1.4",
"winston": "3.2.1"
43 changes: 38 additions & 5 deletions packages/plugins/typescript-mongodb/src/visitor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { TsVisitor, TypeScriptPluginParsedConfig } from 'graphql-codegen-typescript';
import { Directives, TypeScriptPluginConfig } from './index';
import { ASTNode, DirectiveNode, Kind, GraphQLSchema, isEnumType, isObjectType } from 'graphql';
import { BaseVisitorConvertOptions, getConfigValue, ConvertOptions } from 'graphql-codegen-visitor-plugin-common';
import { ASTNode, DirectiveNode, Kind, GraphQLSchema, isEnumType, isObjectType, FieldDefinitionNode } from 'graphql';
import {
BaseVisitorConvertOptions,
getConfigValue,
ConvertOptions,
indent
} from 'graphql-codegen-visitor-plugin-common';

export interface TypeScriptMongoPluginParsedConfig extends TypeScriptPluginParsedConfig {
dbTypeSuffix: string;
@@ -40,6 +45,36 @@ export class TsMongoVisitor extends TsVisitor<TypeScriptPluginConfig, TypeScript
return foundDirective;
}

// FieldDefinition(node: FieldDefinitionNode, key: string | number, parent: any): string {
// const idDirective = this._getDirective(node, Directives.ID);
// const linkDirective = this._getDirective(node, Directives.LINK);
// const columnDirective = this._getDirective(node, Directives.COLUMN);
// const embeddedDirective = this._getDirective(node, Directives.EMBEDDED);
// const originalNode: FieldDefinitionNode = parent[key];

// if (idDirective !== null) {
// return indent(
// `${this.config.immutableTypes ? 'readonly ' : ''}${this.config.idFieldName}: ${this.config.objectIdType},`
// );
// } else if (linkDirective !== null) {
// const type = this._argumentsTransformer.wrapAstTypeWithModifiers(
// this.convertName(originalNode, { suffix: this.config.dbTypeSuffix }) + `['${this.config.idFieldName}']`,
// originalNode.type
// );
// const addOptionalSign = !this.config.avoidOptionals && originalNode.type.kind !== 'NonNullType';

// return indent(
// `${this.config.immutableTypes ? 'readonly ' : ''}${node.name}${addOptionalSign ? '?' : ''}: ${type},`
// );
// } else if (columnDirective !== null) {
// return super.FieldDefinition(node, key, parent);
// } else if (embeddedDirective !== null) {
// return super.FieldDefinition(node, key, parent);
// }

// return null;
// }

protected convertName(node: ASTNode | string, options?: BaseVisitorConvertOptions & ConvertOptions): string {
if (typeof node !== 'string') {
if (node.kind === Kind.OBJECT_TYPE_DEFINITION) {
@@ -55,11 +90,9 @@ export class TsMongoVisitor extends TsVisitor<TypeScriptPluginConfig, TypeScript
if (isEnumType(actualType) && this.config.enumsAsString) {
return this.scalars.String;
} else if (isObjectType(actualType)) {
const entityDirective = this._getDirective(actualType.astNode, Directives.ENTITY);

return super.convertName(node, {
...options,
...(entityDirective ? { suffix: this.config.dbTypeSuffix } : {})
suffix: this.config.dbTypeSuffix
});
}

Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ describe('TypeScript Mongo', () => {
name: String @column
gender: Gender @column
someLink: LinkType @link
linkWithoutDirective: LinkType
multipleLinks: [LinkType] @link
fieldWithMap: String @column @map(path: "profile.inner.field")
columnWithOverride: String @column(overrideType: "number")
@@ -44,10 +45,7 @@ describe('TypeScript Mongo', () => {
}
`);

// console.log(schema.getType('User').astNode.directives);

it('Should generate the correct name for type', async () => {
const result = await plugin(schema, [], {}, { outputFile: '' });
// console.log(result);
});
});
673 changes: 648 additions & 25 deletions yarn.lock

Large diffs are not rendered by default.