This repository has been archived by the owner on May 26, 2023. It is now read-only.
forked from graphql/graphql-js
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract 'printLocation' & 'printSourceLocation' functions (graphql#1984)
Context: facebook/relay#2752 (comment)
- Loading branch information
1 parent
3ddf148
commit a9a21f3
Showing
8 changed files
with
157 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
// @flow strict | ||
|
||
export { GraphQLError } from './GraphQLError'; | ||
export { GraphQLError, printError } from './GraphQLError'; | ||
|
||
export { syntaxError } from './syntaxError'; | ||
|
||
export { locatedError } from './locatedError'; | ||
|
||
export { printError } from './printError'; | ||
|
||
export { formatError } from './formatError'; | ||
export type { GraphQLFormattedError } from './formatError'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// @flow strict | ||
|
||
import { expect } from 'chai'; | ||
import { describe, it } from 'mocha'; | ||
|
||
import dedent from '../../jsutils/dedent'; | ||
import { Source } from '../../language'; | ||
import { printSourceLocation } from '../printLocation'; | ||
|
||
describe('printLocation', () => { | ||
it('prints single digit line number with no padding', () => { | ||
const result = printSourceLocation( | ||
new Source('*', 'Test', { line: 9, column: 1 }), | ||
{ line: 1, column: 1 }, | ||
); | ||
|
||
expect(result + '\n').to.equal(dedent` | ||
Test:9:1 | ||
9: * | ||
^ | ||
`); | ||
}); | ||
|
||
it('prints an line numbers with correct padding', () => { | ||
const result = printSourceLocation( | ||
new Source('*\n', 'Test', { line: 9, column: 1 }), | ||
{ line: 1, column: 1 }, | ||
); | ||
|
||
expect(result + '\n').to.equal(dedent` | ||
Test:9:1 | ||
9: * | ||
^ | ||
10: | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters