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

Schema View Comments Fixes #918

Merged
merged 11 commits into from
Jan 14, 2019
4 changes: 1 addition & 3 deletions packages/graphql-playground-electron/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3695,7 +3695,6 @@ [email protected]:
graphql-config-extension-prisma@^0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/graphql-config-extension-prisma/-/graphql-config-extension-prisma-0.2.5.tgz#f67db5b6f882ac76096fb2e68a18ec81c7d51fd2"
integrity sha512-7Qh3TzZS3hwZpJbTNfTHXBM6UbzV7DMik9Mc95Rz76yTAs7Wr83xBFsH4Ap1NWlqBgANfO3cLLI4YomDJmO5SA==
dependencies:
graphql-config "2.2.1"
prisma-yml "1.20.0-beta.18"
Expand Down Expand Up @@ -3766,10 +3765,9 @@ graphql-playground-html@^1.6.0:
version "1.6.5"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.6.5.tgz#0de1a68db891f7356312cf03dcf371d67388e95a"

[email protected]:
graphql-playground-react@^1.7.11:
version "1.7.11"
resolved "https://registry.yarnpkg.com/graphql-playground-react/-/graphql-playground-react-1.7.11.tgz#a45a1c500de9c4c22a32e3c00ada17cd1a154785"
integrity sha512-ndEoQRHY313mQ+m017KfRcUwCS7b0F+bc67uLShHSpN071oieOI86RTgf9o87Ylq5RI2CfyKRSZyCle6EBooGg==
dependencies:
apollo-link "^1.0.7"
apollo-link-http "^1.3.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function getTypeInstance(type) {
}

// Adds Line Breaks to Schema View
function addLineBreaks(sdl: string, commentsDisabled?: boolean) {
function addLineBreaks(sdl: string, commentsDisabled: boolean = true) {
const noNewLines = sdl.replace(/^\s*$(?:\r\n?|\n)/gm, '')
// Line Break all Brackets
const breakBrackets = noNewLines.replace(/[}]/gm, '$&\r\n')
Expand All @@ -83,10 +83,10 @@ function addLineBreaks(sdl: string, commentsDisabled?: boolean) {
// Returns a prettified schema
export function getSDL(
schema: GraphQLSchema | null | undefined,
commentsDisabled: boolean,
commentsDisabled: boolean = true,
) {
if (schema instanceof GraphQLSchema) {
const rawSdl = printSchema(schema, { commentDescriptions: false })
const rawSdl = printSchema(schema, { commentDescriptions: true })
if (commentsDisabled) {
// Removes Comments but still has new lines
const sdlWithNewLines = rawSdl.replace(/(\#[\w\'\s\r\n\*](.*)$)/gm, '')
Expand Down