Skip to content

Commit

Permalink
Fix: make public API compatible with 'exactOptionalPropertyTypes' (#3670
Browse files Browse the repository at this point in the history
)
  • Loading branch information
IvanGoncharov authored Jul 21, 2022
1 parent ffe37cb commit bef5534
Show file tree
Hide file tree
Showing 17 changed files with 178 additions and 150 deletions.
16 changes: 16 additions & 0 deletions integrationTests/ts/kitchenSink-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { GraphQLScalarType } from 'graphql/type';
import { GraphQLError } from 'graphql/error';
import type { NameNode } from 'graphql/language';
import { Kind } from 'graphql/language';

// Test subset of public APIs with "exactOptionalPropertyTypes" flag enabled
new GraphQLScalarType({
name: 'SomeScalar',
serialize: undefined,
parseValue: undefined,
parseLiteral: undefined,
});

new GraphQLError('test', { nodes: undefined });

const nameNode: NameNode = { kind: Kind.NAME, loc: undefined, value: 'test' };
5 changes: 3 additions & 2 deletions integrationTests/ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"compilerOptions": {
"module": "commonjs",
"lib": ["es2019", "es2020.promise", "es2020.bigint", "es2020.string"],
"strict": true,
"noEmit": true,
"types": []
"types": [],
"strict": true,
"exactOptionalPropertyTypes": true
}
}
2 changes: 1 addition & 1 deletion src/error/GraphQLError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface GraphQLErrorExtensions {
}

export interface GraphQLErrorOptions {
nodes?: ReadonlyArray<ASTNode> | ASTNode | null;
nodes?: ReadonlyArray<ASTNode> | ASTNode | null | undefined;
source?: Maybe<Source>;
positions?: Maybe<ReadonlyArray<number>>;
path?: Maybe<ReadonlyArray<string | number>>;
Expand Down
4 changes: 2 additions & 2 deletions src/execution/__tests__/union-interface-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class Cat {

class Person {
name: string;
pets?: ReadonlyArray<Dog | Cat>;
friends?: ReadonlyArray<Dog | Cat | Person>;
pets: ReadonlyArray<Dog | Cat> | undefined;
friends: ReadonlyArray<Dog | Cat | Person> | undefined;

constructor(
name: string,
Expand Down
2 changes: 1 addition & 1 deletion src/execution/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export function getArgumentValues(
*/
export function getDirectiveValues(
directiveDef: GraphQLDirective,
node: { readonly directives?: ReadonlyArray<DirectiveNode> },
node: { readonly directives?: ReadonlyArray<DirectiveNode> | undefined },
variableValues?: Maybe<ObjMap<unknown>>,
): undefined | { [argument: string]: unknown } {
const directiveNode = node.directives?.find(
Expand Down
Loading

0 comments on commit bef5534

Please sign in to comment.