Skip to content

printSchema: creates invalid block strings for descriptions #2577

@IvanGoncharov

Description

@IvanGoncharov

Not every string can be represented as block string but currently printSchema uses block strings for all descriptions.
Example:

const { buildSchema, parse, printSchema } = require('./dist');
const schema = buildSchema('" " scalar Foo');
const printedSDL = printSchema(schema);
console.log(printedSDL);
// """ """
// scalar Foo

console.log(printSchema(buildSchema(printedSDL)));
// """"""
// scalar Foo

We should add a new utility function (in blockString.js) that checks if the string can be represented as a block string and use it inside printSchema.js.
Based on our previous experience with block strings it would be hard to cover all edge cases so I strongly suggest writing fuzzing test for this new function, similar to this one:

it('correctly print random strings', () => {

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions