Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify printSchema directive printing #3075

Merged
merged 1 commit into from May 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/utilities/printSchema.js
Expand Up @@ -18,7 +18,7 @@ import type {
GraphQLInputObjectType,
} from '../type/definition';
import { isIntrospectionType } from '../type/introspection';
import { GraphQLString, isSpecifiedScalarType } from '../type/scalars';
import { isSpecifiedScalarType } from '../type/scalars';
import {
DEFAULT_DEPRECATION_REASON,
isSpecifiedDirective,
Expand Down Expand Up @@ -282,9 +282,9 @@ function printDeprecated(reason: ?string): string {
if (reason == null) {
return '';
}
const reasonAST = astFromValue(reason, GraphQLString);
if (reasonAST && reason !== DEFAULT_DEPRECATION_REASON) {
return ' @deprecated(reason: ' + print(reasonAST) + ')';
if (reason !== DEFAULT_DEPRECATION_REASON) {
const astValue = print({ kind: 'StringValue', value: reason });
return ` @deprecated(reason: ${astValue})`;
}
return ' @deprecated';
}
Expand All @@ -293,13 +293,8 @@ function printSpecifiedByURL(scalar: GraphQLScalarType): string {
if (scalar.specifiedByURL == null) {
return '';
}
const url = scalar.specifiedByURL;
const urlAST = astFromValue(url, GraphQLString);
invariant(
urlAST,
'Unexpected null value returned from `astFromValue` for specifiedByURL',
);
return ' @specifiedBy(url: ' + print(urlAST) + ')';
const astValue = print({ kind: 'StringValue', value: scalar.specifiedByURL });
return ` @specifiedBy(url: ${astValue})`;
}

function printDescription(
Expand Down