Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dotansimha committed Mar 6, 2019
1 parent 35695be commit d806787
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 28 deletions.
5 changes: 0 additions & 5 deletions packages/graphql-codegen-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@
"@types/js-yaml": "3.12.0",
"@types/listr": "0.13.0",
"@types/log-symbols": "2.0.0",
"graphql-codegen-add": "0.18.0",
"graphql-codegen-time": "0.18.0",
"graphql-codegen-typescript-client": "0.18.0",
"graphql-codegen-typescript-common": "0.18.0",
"graphql-codegen-typescript-server": "0.18.0",
"ts-jest": "24.0.0"
},
"main": "./dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/typescript-resolvers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TypeScriptResolversVisitor } from './visitor';

export interface TypeScriptResolversPluginConfig extends RawResolversConfig {
avoidOptionals?: boolean;
immutableTypes?: boolean;
}

export const plugin: PluginFunction<TypeScriptResolversPluginConfig> = (
Expand Down
15 changes: 13 additions & 2 deletions packages/plugins/typescript-resolvers/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TypeScriptOperationVariablesToObject } from 'graphql-codegen-typescript

export interface ParsedTypeScriptResolversConfig extends ParsedResolversConfig {
avoidOptionals: boolean;
immutableTypes: boolean;
}

export class TypeScriptResolversVisitor extends BaseResolversVisitor<
Expand All @@ -17,13 +18,19 @@ export class TypeScriptResolversVisitor extends BaseResolversVisitor<
super(
pluginConfig,
{
avoidOptionals: pluginConfig.avoidOptionals || false
avoidOptionals: pluginConfig.avoidOptionals || false,
immutableTypes: pluginConfig.immutableTypes || false
} as any,
schema
);
autoBind(this);
this.setVariablesTransformer(
new TypeScriptOperationVariablesToObject(this.config.scalars, this.convertName, this.config.avoidOptionals)
new TypeScriptOperationVariablesToObject(
this.config.scalars,
this.convertName,
this.config.avoidOptionals,
this.config.immutableTypes
)
);
}

Expand All @@ -43,6 +50,10 @@ export class TypeScriptResolversVisitor extends BaseResolversVisitor<
return `Maybe<${super.ListType(node)}>`;
}

protected wrapWithListType(str: string): string {
return `${this.config.immutableTypes ? 'ReadonlyArray' : 'Array'}<${str}>`;
}

NamedType(node: NamedTypeNode): string {
return `Maybe<${super.NamedType(node)}>`;
}
Expand Down
90 changes: 69 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,10 @@
version "14.0.7"
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-14.0.7.tgz#daa09397220a68ce1cbb3f76a315ff3cd92312f6"

"@types/[email protected]":
version "0.0.43"
resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-0.0.43.tgz#1eb0bbb4648e6cc568bd396c1e989f620ad01273"
"@types/[email protected]":
version "0.0.44"
resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-0.0.44.tgz#60ce954581cfdf44ad3899ec4cdc5fbe3fef1694"
integrity sha512-ugbhy1yBtCz5iTWYF+AGRS/UcMcWicdyHhxl9VaeFYc3ueg0CCssthQLB3rIcIOeGtfG6WPEvHdLu/IjKYfefg==
dependencies:
"@types/rx" "*"
"@types/through" "*"
Expand Down Expand Up @@ -1426,6 +1427,14 @@ [email protected], address@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/address/-/address-1.0.3.tgz#b5f50631f8d6cec8bd20c963963afb55e06cbce9"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-2.0.0.tgz#65bd82beba40097eacb2f1077a5b55c593b18abc"
integrity sha512-xA1VQPApQdDehIIpS3gBFkMGDRb9pDYwZPVUOoX8A0lU3GB0mjiACqsa9ByBurU53erhjamf5I4VNRitCfXhjg==
dependencies:
clean-stack "^2.0.0"
indent-string "^3.0.0"

ajv-errors@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d"
Expand Down Expand Up @@ -1716,10 +1725,10 @@ [email protected]:
source-map-support "^0.5.3"
webpack-log "^1.2.0"

aws-sdk@2.410.0:
version "2.410.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.410.0.tgz#e3f912cfc411eb0a1c77ec2bc90a7b7c383f7747"
integrity sha512-1ekVT5gr1m2yJXHZbHb8TAJogLA3Xj//b7yffHNXScAjFx2KNE+hmJ29J716372C0HDNgIPTKqWBp+lsYhvrjA==
aws-sdk@2.411.0:
version "2.411.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.411.0.tgz#1a6df6c4eed402b43a047c57eaef839279718b34"
integrity sha512-8SqJeIoXDfOu4dyiMfaw/outfkXiwDV8cZcGjFD7D+qyAipGuJc+rnzNwAzeKedAz+1KZpxOXrrovDJWKAik5g==
dependencies:
buffer "4.9.1"
events "1.1.1"
Expand Down Expand Up @@ -2553,6 +2562,11 @@ [email protected]:
dependencies:
source-map "~0.6.0"

clean-stack@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.0.0.tgz#301bfa9e8dd2d3d984c0e542f7aa67b996f63e0a"
integrity sha512-VEoL9Qh7I8s8iHnV53DaeWSt8NJ0g3khMfK6NiCPB7H657juhro+cSw2O88uo3bo0c0X5usamtXk0/Of0wXa5A==

cli-cursor@^2.0.0, cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
Expand Down Expand Up @@ -3424,11 +3438,7 @@ deep-is@~0.1.3:
version "0.1.3"
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"

[email protected]:
version "3.1.0"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-3.1.0.tgz#a612626ce4803da410d77554bfd80361599c034d"

deepmerge@^3.0.0:
[email protected], deepmerge@^3.0.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-3.2.0.tgz#58ef463a57c08d376547f8869fdc5bcee957f44e"

Expand Down Expand Up @@ -4875,6 +4885,32 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6
version "4.1.15"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00"

[email protected]:
version "0.17.0"
resolved "https://registry.yarnpkg.com/graphql-codegen-typescript-client/-/graphql-codegen-typescript-client-0.17.0.tgz#cafb228f6ed7b4f8d202ab58f7a162d73ead236b"
integrity sha512-SHrG1oVMKqIm4xirxZFlHdeQHpDpXJLmkPc6JNS0Mz4g14//muiP3tDlSJRtxSCcC2azRc/k+YkZ4yWFKoLDxQ==
dependencies:
graphql-codegen-core "0.17.0"
graphql-codegen-plugin-helpers "0.17.0"
graphql-codegen-typescript-common "0.17.0"

[email protected]:
version "0.17.0"
resolved "https://registry.yarnpkg.com/graphql-codegen-typescript-common/-/graphql-codegen-typescript-common-0.17.0.tgz#76cfeefa92ee8420f2c9a687576fd5ac3d6e14fb"
integrity sha512-tUaJB4fuHHgZa1JFroe5V4kIn69HKmKwaHEvizXhuAmJUnHGThzjnn71Ot0FMSpF6RLcMf/adDsNts/BQrUEYg==
dependencies:
change-case "3.1.0"
common-tags "1.8.0"
graphql-codegen-core "0.17.0"
graphql-codegen-plugin-helpers "0.17.0"

[email protected]:
version "0.17.0"
resolved "https://registry.yarnpkg.com/graphql-codegen-typescript-server/-/graphql-codegen-typescript-server-0.17.0.tgz#6c6e70cfe72d73db33662469d83c3a0edcaf3178"
integrity sha512-70EqTJTJ1K8nVvhkpTdzmY4k04/OV1KsGEZeQeH7rPtVxJ2acrxlpFAJIqjQgsCPSnuZJotQfZDNAWmn4bd5nQ==
dependencies:
graphql-codegen-typescript-common "0.17.0"

[email protected]:
version "2.0.1"
resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-2.0.1.tgz#d34a9bdf1d7360af7b01db9b20260a342ddc7390"
Expand Down Expand Up @@ -4943,9 +4979,10 @@ graphql-request@^1.5.0:
dependencies:
cross-fetch "2.2.2"

[email protected]:
version "0.5.0"
resolved "https://registry.yarnpkg.com/graphql-tag-pluck/-/graphql-tag-pluck-0.5.0.tgz#81f5dee3a6ca829f205ab032336be7b107398b2e"
[email protected]:
version "0.6.0"
resolved "https://registry.yarnpkg.com/graphql-tag-pluck/-/graphql-tag-pluck-0.6.0.tgz#d03ab981cd8d31e564d37f8b9bac94a523dc29dd"
integrity sha512-C1SRw5zZtl7CN7mv6Q0abFVSJwG8M+FniFCPqWD+AjQMj9igNPthraMUQ02KSo+j19khR60mksqmFN3BwboFaw==
dependencies:
"@babel/parser" "^7.2.0"
"@babel/traverse" "^7.1.6"
Expand All @@ -4957,18 +4994,21 @@ [email protected]:
version "2.10.1"
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.10.1.tgz#10aa41f1cd8fae5373eaf11f1f67260a3cad5e02"

[email protected]:
version "0.0.5"
resolved "https://registry.yarnpkg.com/graphql-toolkit/-/graphql-toolkit-0.0.5.tgz#9e6ebe3d4b33fc329e5ee3b7775bfe7fba2f48a5"
[email protected]:
version "0.1.1"
resolved "https://registry.yarnpkg.com/graphql-toolkit/-/graphql-toolkit-0.1.1.tgz#b1d50afeb9f11ba90f93e896ca8f48308ca7b549"
integrity sha512-MLTqeYi0k1KVEeVEPMLBoeAYWWOUc8OCu3DmfzHMHtahz+RatV9zBlRA0vghWAjzJP7/zH4xM9bJldF5RaV7GQ==
dependencies:
deepmerge "3.1.0"
aggregate-error "2.0.0"
deepmerge "3.2.0"
glob "7.1.3"
graphql-import "0.7.1"
graphql-tag-pluck "0.5.0"
graphql-tag-pluck "0.6.0"
is-glob "4.0.0"
is-valid-path "0.1.1"
lodash "4.17.11"
request "2.88.0"
tslib "^1.9.3"
valid-url "1.0.9"

[email protected]:
Expand Down Expand Up @@ -6706,7 +6746,15 @@ js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"

[email protected], js-yaml@^3.10.0, js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0:
[email protected]:
version "3.12.2"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.2.tgz#ef1d067c5a9d9cb65bd72f285b5d8105c77f14fc"
integrity sha512-QHn/Lh/7HhZ/Twc7vJYQTkjuCa0kaCcDcjK5Zlk2rvnUpy7DxMJ23+Jc2dcyvltwQVg1nygAVlB2oRDFHoRS5Q==
dependencies:
argparse "^1.0.7"
esprima "^4.0.0"

js-yaml@^3.10.0, js-yaml@^3.12.0, js-yaml@^3.7.0, js-yaml@^3.9.0:
version "3.12.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.1.tgz#295c8632a18a23e054cf5c9d3cecafe678167600"
dependencies:
Expand Down

0 comments on commit d806787

Please sign in to comment.