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

printSchema produces incorrect AST for descriptions ending in \ (backslash) #2512

Closed
pcarrier opened this issue Apr 16, 2020 · 5 comments · Fixed by #2560
Closed

printSchema produces incorrect AST for descriptions ending in \ (backslash) #2512

pcarrier opened this issue Apr 16, 2020 · 5 comments · Fixed by #2560
Assignees
Labels

Comments

@pcarrier
Copy link
Contributor

pcarrier commented Apr 16, 2020

import { buildASTSchema, parse, printSchema } from 'graphql';
console.log(printSchema(buildASTSchema(parse(`"Example\\\\" scalar Foo`))));

=>

"""Example\"""
scalar Foo

Which parse does not accept.

@IvanGoncharov
Copy link
Member

@pcarrier Thanks for reporting 👍
Definitely something we need to address.

@IvanGoncharov IvanGoncharov added this to the v15.1.0 milestone May 6, 2020
@thenamankumar
Copy link
Contributor

@IvanGoncharov what should be the correct result?

@IvanGoncharov
Copy link
Member

@hereisnaman It should be reproducible even with:

const sdl = `
"""Example\\"""
scalar Foo
`;
expect(print(parse(sdl))).to.equal(sdl);

So it's not an issue with printSchema it's an issue with how we are printing block strings in general.

@pcarrier
Copy link
Contributor Author

pcarrier commented May 17, 2020

Oh yeah sorry I didn't mean to imply this was specific to schemas, absolutely a general printer issue, it's just where we reproduced it by leveraging the wealth of customer data our platform manages and that's the easiest way to make GraphQL-js produce those strings itself I could think of.

@IvanGoncharov
Copy link
Member

@pcarrier No worries.
I'm mentoring @hereisnaman as part of "Google Summer of Code" and this issue is an excellent opportunity for him to learn how parser/printer works.
So my comments intended to guide him in the right direction so he could figure how to fix this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants