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

Fix prettier incorrect query #775

Merged
merged 1 commit into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function* runQuerySaga(action) {
headers,
credentials: settings['request.credentials'],
}

const { link, subscriptionClient } = linkCreator(lol)
yield put(setCurrentQueryStartTime(new Date()))

Expand Down
10 changes: 8 additions & 2 deletions packages/graphql-playground-react/src/state/sessions/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,14 @@ function* addToHistory({ payload }) {
function* prettifyQuery() {
const { query } = yield select(getSelectedSession)
const settings = yield select(getSettings)
const prettyQuery = prettify(query, settings['prettier.printWidth'])
yield put(editQuery(prettyQuery))
try {
const prettyQuery = prettify(query, settings['prettier.printWidth'])
yield put(editQuery(prettyQuery))
} catch (e) {
// TODO show erros somewhere
// tslint:disable-next-line
console.log(e)
}
}

export const sessionsSagas = [
Expand Down
15 changes: 5 additions & 10 deletions packages/graphql-playground-react/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,9 @@ export function safely(cb: any) {
}

export function prettify(query: string, printWidth: number) {
try {
return prettier.format(query, {
parser: 'graphql',
printWidth,
plugins: [graphql],
})
} catch (e) {
//TODO show erros somewhere
console.log(e)
}
return prettier.format(query, {
parser: 'graphql',
printWidth,
plugins: [graphql],
})
}