Skip to content

Commit

Permalink
Remove deprecate printError/formatError methods
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 12, 2022
1 parent f44cb4e commit 6db5c9a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 41 deletions.
20 changes: 0 additions & 20 deletions src/error/GraphQLError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,23 +237,3 @@ export interface GraphQLFormattedError {
*/
readonly extensions?: { [key: string]: unknown };
}

/**
* Prints a GraphQLError to a string, representing useful location information
* about the error's position in the source.
*
* @deprecated Please use `error.toString` instead. Will be removed in v17
*/
export function printError(error: GraphQLError): string {
return error.toString();
}

/**
* Given a GraphQLError, format it according to the rules described by the
* Response Format, Errors section of the GraphQL Specification.
*
* @deprecated Please use `error.toJSON` instead. Will be removed in v17
*/
export function formatError(error: GraphQLError): GraphQLFormattedError {
return error.toJSON();
}
14 changes: 1 addition & 13 deletions src/error/__tests__/GraphQLError-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';
import { Source } from '../../language/source';

import { formatError, GraphQLError, printError } from '../GraphQLError';
import { GraphQLError } from '../GraphQLError';

const source = new Source(dedent`
{
Expand Down Expand Up @@ -223,11 +223,6 @@ describe('GraphQLError', () => {
});

describe('toString', () => {
it('Deprecated: prints an error using printError', () => {
const error = new GraphQLError('Error');
expect(printError(error)).to.equal('Error');
});

it('prints an error without location', () => {
const error = new GraphQLError('Error without location');
expect(error.toString()).to.equal('Error without location');
Expand Down Expand Up @@ -294,13 +289,6 @@ describe('toString', () => {
});

describe('toJSON', () => {
it('Deprecated: format an error using formatError', () => {
const error = new GraphQLError('Example Error');
expect(formatError(error)).to.deep.equal({
message: 'Example Error',
});
});

it('includes path', () => {
const error = new GraphQLError('msg', { path: ['path', 3, 'to', 'field'] });

Expand Down
2 changes: 1 addition & 1 deletion src/error/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { GraphQLError, printError, formatError } from './GraphQLError';
export { GraphQLError } from './GraphQLError';
export type {
GraphQLErrorOptions,
GraphQLFormattedError,
Expand Down
8 changes: 1 addition & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,7 @@ export {
export type { ValidationRule } from './validation/index';

// Create, format, and print GraphQL errors.
export {
GraphQLError,
syntaxError,
locatedError,
printError,
formatError,
} from './error/index';
export { GraphQLError, syntaxError, locatedError } from './error/index';

export type {
GraphQLErrorOptions,
Expand Down

0 comments on commit 6db5c9a

Please sign in to comment.