Skip to content

Commit

Permalink
Fix rawSDL issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Jun 29, 2021
1 parent 614c08c commit e323e9e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/utils/src/parse-graphql-sdl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import { GraphQLParseOptions } from './Interfaces';

export function parseGraphQLSDL(location: string | undefined, rawSDL: string, options: GraphQLParseOptions = {}) {
let document: DocumentNode;
const sdl: string = rawSDL;

try {
if (options.commentDescriptions && sdl.includes('#')) {
if (options.commentDescriptions && rawSDL.includes('#')) {
document = transformCommentsToDescriptions(rawSDL, options);

// If noLocation=true, we need to make sure to print and parse it again, to remove locations,
Expand All @@ -28,10 +27,10 @@ export function parseGraphQLSDL(location: string | undefined, rawSDL: string, op
document = parse(print(document), options);
}
} else {
document = parse(new GraphQLSource(sdl, location), options);
document = parse(new GraphQLSource(rawSDL, location), options);
}
} catch (e) {
if (e.message.includes('EOF') && sdl.replace(/(\#[^*]*)/g, '').trim() === '') {
if (e.message.includes('EOF') && rawSDL.replace(/(\#[^*]*)/g, '').trim() === '') {
document = {
kind: Kind.DOCUMENT,
definitions: [],
Expand All @@ -42,6 +41,7 @@ export function parseGraphQLSDL(location: string | undefined, rawSDL: string, op
}

return {
rawSDL,
location,
document,
};
Expand Down

0 comments on commit e323e9e

Please sign in to comment.