Skip to content

Commit 2ef897e

Browse files
committed
Factor into getIntrospectionQuery
1 parent f385976 commit 2ef897e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/utilities/getIntrospectionQuery.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ export interface IntrospectionOptions {
3838
* Default: false
3939
*/
4040
oneOf?: boolean;
41+
42+
/**
43+
* Choose the type of nullability you would like to see.
44+
*
45+
* - AUTO: SEMANTIC if errorPropagation is set to false, otherwise TRADITIONAL
46+
* - TRADITIONAL: all GraphQLSemanticNonNull will be unwrapped
47+
* - SEMANTIC: all GraphQLNonNull will be converted to GraphQLSemanticNonNull
48+
* - FULL: the true nullability will be returned
49+
*
50+
*/
51+
nullability?: 'AUTO' | 'TRADITIONAL' | 'SEMANTIC' | 'FULL';
4152
}
4253

4354
/**
@@ -52,6 +63,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
5263
schemaDescription: false,
5364
inputValueDeprecation: false,
5465
oneOf: false,
66+
nullability: null,
5567
...options,
5668
};
5769

@@ -70,6 +82,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
7082
return optionsWithDefault.inputValueDeprecation ? str : '';
7183
}
7284
const oneOf = optionsWithDefault.oneOf ? 'isOneOf' : '';
85+
const nullability = optionsWithDefault.nullability;
7386

7487
return `
7588
query IntrospectionQuery {
@@ -105,7 +118,7 @@ export function getIntrospectionQuery(options?: IntrospectionOptions): string {
105118
args${inputDeprecation('(includeDeprecated: true)')} {
106119
...InputValue
107120
}
108-
type {
121+
type${nullability ? `(nullability: ${nullability})` : ``} {
109122
...TypeRef
110123
}
111124
isDeprecated

0 commit comments

Comments
 (0)