Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 75bf1bf

Browse files
committed
use optionalInputFields instead of inputFieldWhiteList
1 parent a0c3db6 commit 75bf1bf

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

src/TypeScriptGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function createVisitor(options: TypeGeneratorOptions) {
285285
existingFragmentNames: options.existingFragmentNames,
286286
generatedInputObjectTypes: {},
287287
generatedFragments: new Set(),
288-
inputFieldWhiteList: options.inputFieldWhiteList,
288+
optionalInputFields: options.optionalInputFields,
289289
relayRuntimeModule: options.relayRuntimeModule,
290290
usedEnums: {},
291291
usedFragments: new Set(),

src/TypeScriptTypeTransformers.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ function transformNonNullableInputType(type: GraphQLInputType, state: State) {
134134

135135
const props = Object.keys(fields)
136136
.map(key => fields[key])
137-
.filter(field => state.inputFieldWhiteList.indexOf(field.name) < 0)
137+
.filter(
138+
field =>
139+
state.optionalInputFields &&
140+
state.optionalInputFields.indexOf(field.name) < 0
141+
)
138142
.map(field => {
139143
const property = ts.createPropertySignature(
140144
[ts.createToken(ts.SyntaxKind.ReadonlyKeyword)],

test/TypeScriptGenerator-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('TypeScriptGenerator with a single artifact directory', () => {
2121
customScalars: {},
2222
enumsHasteModule: null,
2323
existingFragmentNames: new Set(['PhotoFragment']),
24-
inputFieldWhiteList: [],
24+
optionalInputFields: [],
2525
relayRuntimeModule: 'relay-runtime',
2626
useHaste: false,
2727
useSingleArtifactDirectory: true,
@@ -46,7 +46,7 @@ describe('TypeScriptGenerator without a single artifact directory', () => {
4646
customScalars: {},
4747
enumsHasteModule: null,
4848
existingFragmentNames: new Set(['PhotoFragment']),
49-
inputFieldWhiteList: [],
49+
optionalInputFields: [],
5050
relayRuntimeModule: 'relay-runtime',
5151
useHaste: true,
5252
}),

types/relay-compiler/language/RelayLanguagePluginInterface.d.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RelayConcreteNode } from "relay-runtime";
2-
import { Root, Fragment, IRTransform } from "../../graphql-compiler";
2+
import { Fragment, IRTransform, Root } from "../../graphql-compiler";
33

44
export type GraphQLTag = {
55
keyName: string | null;
@@ -33,23 +33,20 @@ export type FormatModule = (
3333
}
3434
) => string;
3535

36-
export type GraphQLTagFinder = (
37-
text: string,
38-
filePath: string
39-
) => Array<GraphQLTag>;
36+
export type GraphQLTagFinder = (text: string, filePath: string) => GraphQLTag[];
4037

4138
export interface TypeGeneratorOptions {
4239
readonly customScalars: { [type: string]: string };
4340
readonly useHaste: boolean;
4441
readonly enumsHasteModule: string | null;
4542
readonly existingFragmentNames: Set<string>;
46-
readonly inputFieldWhiteList: ReadonlyArray<string>;
43+
readonly optionalInputFields: ReadonlyArray<string>;
4744
readonly relayRuntimeModule: string;
4845
readonly useSingleArtifactDirectory: boolean;
4946
}
5047

5148
export interface TypeGenerator {
52-
transforms: Array<IRTransform>;
49+
transforms: IRTransform[];
5350
generate: (node: Root | Fragment, options: TypeGeneratorOptions) => string;
5451
}
5552

0 commit comments

Comments
 (0)