Skip to content

Commit

Permalink
(core) - Remove deprecated operationName property from Operations (#1357
Browse files Browse the repository at this point in the history
)

* Remove deprecated operationName property from Operation

* Add changeset

* Bump bindings by minor to adopt new major @urql/core
  • Loading branch information
kitten authored Feb 10, 2021
1 parent 97689ff commit 9a1f123
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 113 deletions.
10 changes: 10 additions & 0 deletions .changeset/plenty-carrots-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@urql/core': major
'@urql/preact': minor
'@urql/svelte': minor
'@urql/vue': minor
'urql': minor
---

Remove deprecated `operationName` property from `Operation`s. The new `Operation.kind` property is now preferred. If you're creating new operations you may also use the `makeOperation` utility instead.
When upgrading `@urql/core` please ensure that your package manager didn't install any duplicates of it. You may deduplicate it manually using `npx yarn-deduplicate` (for Yarn) or `npm dedupe` (for npm).
10 changes: 5 additions & 5 deletions exchanges/graphcache/src/operations/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,23 +94,23 @@ export const startWrite = (
) => {
const operation = getMainOperation(request.query);
const result: WriteResult = { data, dependencies: getCurrentDependencies() };
const operationName = store.rootFields[operation.operation];
const kind = store.rootFields[operation.operation];

const ctx = makeContext(
store,
normalizeVariables(operation, request.variables),
getFragments(request.query),
operationName,
operationName,
kind,
kind,
!!isOptimistic,
error
);

if (process.env.NODE_ENV !== 'production') {
pushDebugNode(operationName, operation);
pushDebugNode(kind, operation);
}

writeSelection(ctx, operationName, getSelectionSet(operation), data);
writeSelection(ctx, kind, getSelectionSet(operation), data);

if (process.env.NODE_ENV !== 'production') {
popDebugNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -185,7 +184,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -357,7 +355,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -531,7 +528,6 @@ Object {
},
"key": 3,
"kind": "mutation",
"operationName": "mutation",
"query": Object {
"__key": 3781860981,
"definitions": Array [
Expand Down Expand Up @@ -681,7 +677,6 @@ Object {
},
"key": 3,
"kind": "mutation",
"operationName": "mutation",
"query": Object {
"__key": 1193185401,
"definitions": Array [
Expand Down
3 changes: 0 additions & 3 deletions exchanges/refocus/src/refocusExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,5 @@ it(`attaches a listener and redispatches queries on call`, () => {
key: 1,
query: queryOne,
kind: 'query',

// TODO: Remove this when the deprecated "operationName" property is removed
operationName: 'query',
});
});
3 changes: 0 additions & 3 deletions packages/core/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ describe('synchronous methods', () => {
context: expect.anything(),
key: expect.any(Number),
kind: 'query',

// TODO: Remove this when the deprecated `operationName` property is removed
operationName: 'query',
},
});
});
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/exchanges/__snapshots__/fetch.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -185,7 +184,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -357,7 +355,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Object {
},
"key": 4,
"kind": "subscription",
"operationName": "subscription",
"query": Object {
"__key": 2616620656,
"definitions": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -175,7 +174,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -335,7 +333,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -499,7 +496,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down Expand Up @@ -679,7 +675,6 @@ Object {
},
"key": 2,
"kind": "query",
"operationName": "query",
"query": Object {
"__key": 3044551916,
"definitions": Array [
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export interface Operation<Data = any, Variables = any>
extends GraphQLRequest<Data, Variables> {
readonly kind: OperationType;
context: OperationContext;

/** @deprecated use Operation.kind instead */
readonly operationName: OperationType;
}

/** Resulting data from an [operation]{@link Operation}. */
Expand Down
29 changes: 0 additions & 29 deletions packages/core/src/utils/deprecation.test.ts

This file was deleted.

29 changes: 0 additions & 29 deletions packages/core/src/utils/deprecation.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export * from './stringifyVariables';
export * from './maskTypename';
export * from './withPromise';
export * from './operation';
export * from './deprecation';

export const noop = () => {
/* noop */
Expand Down
16 changes: 0 additions & 16 deletions packages/core/src/utils/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@ import {
OperationContext,
OperationType,
} from '../types';
import { Warning, deprecationWarning } from './deprecation';

// TODO: Remove when the deprecated `operationName` property is removed
const DEPRECATED: Record<string, Warning> = {
operationName: {
key: 'Operation.operationName',
message:
'The "Operation.operationName" property has been deprecated and will be removed in a future release of urql. Use "Operation.kind" instead.',
},
};

function makeOperation<Data = any, Variables = object>(
kind: OperationType,
Expand All @@ -36,12 +26,6 @@ function makeOperation(kind, request, context) {
variables: request.variables,
kind,
context,

get operationName(): OperationType {
deprecationWarning(DEPRECATED.operationName);

return this.kind;
},
};
}

Expand Down
10 changes: 0 additions & 10 deletions scripts/jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,3 @@ global.console = {
jest.spyOn(console, 'log');
jest.spyOn(console, 'warn');
jest.spyOn(console, 'error');

jest.mock('../../packages/core/src/utils/deprecation.ts', () => ({
deprecationWarning({ message }) {
const error = new Error(`Deprecation Warnings are thrown in tests.\n${message}`);
if (!/jest-snapshot|pretty-format|jest-jasmine2/i.test(error.stack)) {
throw error;
}
},
_clearWarnings() {},
}));

0 comments on commit 9a1f123

Please sign in to comment.