Skip to content

Commit 24474fa

Browse files
committed
rename to SemanticNullable
1 parent 0a8b68f commit 24474fa

File tree

10 files changed

+38
-38
lines changed

10 files changed

+38
-38
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"test": "npm run lint && npm run check && npm run testonly && npm run prettier:check && npm run check:spelling && npm run check:integrations",
3939
"lint": "eslint --cache --max-warnings 0 .",
4040
"check": "tsc --pretty",
41-
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts -g 'SemanticOptional allows null values'",
41+
"testonly": "mocha --full-trace src/**/__tests__/**/*-test.ts",
4242
"testonly:cover": "c8 npm run testonly",
4343
"prettier": "prettier --write --list-different .",
4444
"prettier:check": "prettier --check .",

src/execution/__tests__/executor-test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
GraphQLObjectType,
1818
GraphQLScalarType,
1919
GraphQLSemanticNonNull,
20-
GraphQLSemanticOptional,
20+
GraphQLSemanticNullable,
2121
GraphQLUnionType,
2222
} from '../../type/definition';
2323
import { GraphQLBoolean, GraphQLInt, GraphQLString } from '../../type/scalars';
@@ -1339,7 +1339,7 @@ describe('Execute: Handles Semantic Nullability', () => {
13391339
const DataType: GraphQLObjectType = new GraphQLObjectType({
13401340
name: 'DataType',
13411341
fields: () => ({
1342-
a: { type: new GraphQLSemanticOptional(GraphQLString) },
1342+
a: { type: new GraphQLSemanticNullable(GraphQLString) },
13431343
b: { type: new GraphQLSemanticNonNull(GraphQLString) },
13441344
c: { type: new GraphQLNonNull(GraphQLString) },
13451345
d: { type: new GraphQLSemanticNonNull(DeepDataType) }
@@ -1471,7 +1471,7 @@ describe('Execute: Handles Semantic Nullability', () => {
14711471
});
14721472
});
14731473

1474-
it('SemanticOptional allows null values', async () => {
1474+
it('SemanticNullable allows null values', async () => {
14751475
const data = {
14761476
a: () => null,
14771477
b: () => null,
@@ -1497,7 +1497,7 @@ describe('Execute: Handles Semantic Nullability', () => {
14971497
});
14981498
});
14991499

1500-
it('SemanticOptional allows non-null values', async () => {
1500+
it('SemanticNullable allows non-null values', async () => {
15011501
const data = {
15021502
a: () => 'Apple',
15031503
b: () => null,

src/execution/execute.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import {
4444
isNonNullType,
4545
isObjectType,
4646
isSemanticNonNullType,
47-
isSemanticOptionalType,
47+
isSemanticNullableType,
4848
} from '../type/definition';
4949
import {
5050
SchemaMetaFieldDef,
@@ -689,8 +689,8 @@ function completeValue(
689689
return completed;
690690
}
691691

692-
// If field type is SemanticOptional, complete for inner type
693-
if (isSemanticOptionalType(returnType)) {
692+
// If field type is SemanticNullable, complete for inner type
693+
if (isSemanticNullableType(returnType)) {
694694
return completeValue(
695695
exeContext,
696696
returnType.ofType,

src/language/__tests__/parser-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ describe('Parser', () => {
687687
it('parses nullable types', () => {
688688
const result = parseType('MyType?', { useSemanticNullability: true });
689689
expectJSON(result).toDeepEqual(
690-
{ kind: Kind.SEMANTIC_OPTIONAL_TYPE,
690+
{ kind: Kind.SEMANTIC_NULLABLE_TYPE,
691691
loc: { start: 0, end: 7 },
692692
type: {
693693
kind: Kind.NAMED_TYPE,

src/language/__tests__/schema-printer-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ describe('Printer: SDL document', () => {
185185
expect(print(parseType('MyType', { useSemanticNullability: false }))).to.equal(dedent`MyType`);
186186
});
187187

188-
it('prints SemanticOptionalType', () => {
188+
it('prints SemanticNullableType', () => {
189189
expect(print(parseType('MyType?', { useSemanticNullability: true }))).to.equal(dedent`MyType?`);
190190
});
191191

src/language/ast.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export type ASTNode =
162162
| ListTypeNode
163163
| NonNullTypeNode
164164
| SemanticNonNullTypeNode
165-
| SemanticOptionalTypeNode
165+
| SemanticNullableTypeNode
166166
| SchemaDefinitionNode
167167
| OperationTypeDefinitionNode
168168
| ScalarTypeDefinitionNode
@@ -238,7 +238,7 @@ export const QueryDocumentKeys: {
238238
ListType: ['type'],
239239
NonNullType: ['type'],
240240
SemanticNonNullType: ['type'],
241-
SemanticOptionalType: ['type'],
241+
SemanticNullableType: ['type'],
242242

243243
SchemaDefinition: ['description', 'directives', 'operationTypes'],
244244
OperationTypeDefinition: ['type'],
@@ -529,7 +529,7 @@ export type TypeNode =
529529
| ListTypeNode
530530
| NonNullTypeNode
531531
| SemanticNonNullTypeNode
532-
| SemanticOptionalTypeNode;
532+
| SemanticNullableTypeNode;
533533

534534
export interface NamedTypeNode {
535535
readonly kind: Kind.NAMED_TYPE;
@@ -555,8 +555,8 @@ export interface SemanticNonNullTypeNode {
555555
readonly type: NamedTypeNode | ListTypeNode;
556556
}
557557

558-
export interface SemanticOptionalTypeNode {
559-
readonly kind: Kind.SEMANTIC_OPTIONAL_TYPE;
558+
export interface SemanticNullableTypeNode {
559+
readonly kind: Kind.SEMANTIC_NULLABLE_TYPE;
560560
readonly loc?: Location;
561561
readonly type: NamedTypeNode | ListTypeNode;
562562
}

src/language/kinds.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ enum Kind {
3838
LIST_TYPE = 'ListType',
3939
NON_NULL_TYPE = 'NonNullType',
4040
SEMANTIC_NON_NULL_TYPE = 'SemanticNonNullType',
41-
SEMANTIC_OPTIONAL_TYPE = 'SemanticOptionalType',
41+
SEMANTIC_NULLABLE_TYPE = 'SemanticNullableType',
4242

4343
/** Type System Definitions */
4444
SCHEMA_DEFINITION = 'SchemaDefinition',

src/language/parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import type {
5151
SelectionNode,
5252
SelectionSetNode,
5353
SemanticNonNullTypeNode,
54-
SemanticOptionalTypeNode,
54+
SemanticNullableTypeNode,
5555
StringValueNode,
5656
Token,
5757
TypeNode,
@@ -775,8 +775,8 @@ export class Parser {
775775
type,
776776
});
777777
} else if (this.expectOptionalToken(TokenKind.QUESTION_MARK)) {
778-
return this.node<SemanticOptionalTypeNode>(start, {
779-
kind: Kind.SEMANTIC_OPTIONAL_TYPE,
778+
return this.node<SemanticNullableTypeNode>(start, {
779+
kind: Kind.SEMANTIC_NULLABLE_TYPE,
780780
type,
781781
});
782782
} else {

src/language/printer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ const printDocASTReducer: ASTReducer<string> = {
141141
ListType: { leave: ({ type }) => '[' + type + ']' },
142142
NonNullType: { leave: ({ type }) => type + '!' },
143143
SemanticNonNullType: { leave: ({ type }) => type },
144-
SemanticOptionalType: { leave: ({ type }) => type + '?' },
144+
SemanticNullableType: { leave: ({ type }) => type + '?' },
145145

146146
// Type System Definitions
147147

src/type/definition.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export type GraphQLType =
7676
| GraphQLInputObjectType
7777
| GraphQLList<GraphQLType>
7878
>
79-
| GraphQLSemanticOptional<
79+
| GraphQLSemanticNullable<
8080
| GraphQLScalarType
8181
| GraphQLObjectType
8282
| GraphQLInterfaceType
@@ -248,25 +248,25 @@ export function assertSemanticNonNullType(
248248
return type;
249249
}
250250

251-
export function isSemanticOptionalType(
251+
export function isSemanticNullableType(
252252
type: GraphQLInputType,
253-
): type is GraphQLSemanticOptional<GraphQLInputType>;
254-
export function isSemanticOptionalType(
253+
): type is GraphQLSemanticNullable<GraphQLInputType>;
254+
export function isSemanticNullableType(
255255
type: GraphQLOutputType,
256-
): type is GraphQLSemanticOptional<GraphQLOutputType>;
257-
export function isSemanticOptionalType(
256+
): type is GraphQLSemanticNullable<GraphQLOutputType>;
257+
export function isSemanticNullableType(
258258
type: unknown,
259-
): type is GraphQLSemanticOptional<GraphQLType>;
260-
export function isSemanticOptionalType(
259+
): type is GraphQLSemanticNullable<GraphQLType>;
260+
export function isSemanticNullableType(
261261
type: unknown,
262-
): type is GraphQLSemanticOptional<GraphQLType> {
263-
return instanceOf(type, GraphQLSemanticOptional);
262+
): type is GraphQLSemanticNullable<GraphQLType> {
263+
return instanceOf(type, GraphQLSemanticNullable);
264264
}
265265

266-
export function assertSemanticOptionalType(
266+
export function assertSemanticNullableType(
267267
type: unknown,
268-
): GraphQLSemanticOptional<GraphQLType> {
269-
if (!isSemanticOptionalType(type)) {
268+
): GraphQLSemanticNullable<GraphQLType> {
269+
if (!isSemanticNullableType(type)) {
270270
throw new Error(
271271
`Expected ${inspect(type)} to be a GraphQL Semantic-Non-Null type.`,
272272
);
@@ -546,7 +546,7 @@ export class GraphQLSemanticNonNull<T extends GraphQLNullableType> {
546546
}
547547

548548
/**
549-
* Semantic-Non-Null Type Wrapper
549+
* Semantic-Nullable Type Wrapper
550550
*
551551
* A semantic-non-null is a wrapping type which points to another type.
552552
* Semantic-non-null types enforce that their values are never null unless
@@ -569,7 +569,7 @@ export class GraphQLSemanticNonNull<T extends GraphQLNullableType> {
569569
*
570570
* @experimental
571571
*/
572-
export class GraphQLSemanticOptional<T extends GraphQLNullableType> {
572+
export class GraphQLSemanticNullable<T extends GraphQLNullableType> {
573573
readonly ofType: T;
574574

575575
constructor(ofType: T) {
@@ -582,7 +582,7 @@ export class GraphQLSemanticOptional<T extends GraphQLNullableType> {
582582
}
583583

584584
get [Symbol.toStringTag]() {
585-
return 'GraphQLSemanticOptional';
585+
return 'GraphQLSemanticNullable';
586586
}
587587

588588
toString(): string {
@@ -602,10 +602,10 @@ export type GraphQLWrappingType =
602602
| GraphQLList<GraphQLType>
603603
| GraphQLNonNull<GraphQLType>
604604
| GraphQLSemanticNonNull<GraphQLType>
605-
| GraphQLSemanticOptional<GraphQLType>;
605+
| GraphQLSemanticNullable<GraphQLType>;
606606

607607
export function isWrappingType(type: unknown): type is GraphQLWrappingType {
608-
return isListType(type) || isNonNullType(type) || isSemanticNonNullType(type) || isSemanticOptionalType(type);
608+
return isListType(type) || isNonNullType(type) || isSemanticNonNullType(type) || isSemanticNullableType(type);
609609
}
610610

611611
export function assertWrappingType(type: unknown): GraphQLWrappingType {

0 commit comments

Comments
 (0)