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

Remove deprecate printError/formatError methods #3582

Merged
merged 1 commit into from
May 12, 2022
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
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