Skip to content

Commit

Permalink
Runtime deprecation warnings about concurrency field in `createJson…
Browse files Browse the repository at this point in the history
…Query` and `createJsonMutation`
  • Loading branch information
igorkamyshev committed Apr 16, 2024
1 parent 46c3402 commit 121de27
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-ducks-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farfetched/core": minor
---

Runtime deprecation warnings about `concurrency` field in `createJsonQuery` and `createJsonMutation`
5 changes: 0 additions & 5 deletions .changeset/pretty-mails-switch.md

This file was deleted.

4 changes: 4 additions & 0 deletions apps/website/docs/releases/0-13.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ TODO:

This operator is deprecated since [v0.12](/releases/0-12) and will be removed in v0.14. Please read [this ADR](/adr/attach_operation_deprecation) for more information and migration guide.

### `concurrency` operator

Field `concurrency` in `createJsonQuery` and `createJsonMutation` is deprecated since [v0.12](/releases/0-12) and has to be replaced by the [`concurrency` operator](/api/operators/concurrency). Please read [this ADR](/adr/concurrency) for more information and migration guide.

<!--@include: ./0-13.changelog.md-->
4 changes: 4 additions & 0 deletions packages/core/src/mutation/create_json_mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ export function createJsonMutation(config: any): Mutation<any, any, any> {

/* TODO: in future releases we will remove this code and make concurrency a separate function */
if (config.concurrency) {
console.error(
'concurrency field in createJsonMutation is deprecated, please use concurrency operator instead: https://farfetched.pages.dev/adr/concurrency'
);

op.__.meta.flags.concurrencyFieldUsed = true;
}

Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/query/create_json_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,19 @@ export function createJsonQuery(config: any) {

/* TODO: in future releases we will remove this code and make concurrency a separate function */
if (config.concurrency) {
console.error(
'concurrency field in createJsonQuery is deprecated, please use concurrency operator instead: https://farfetched.pages.dev/adr/concurrency'
);

op.__.meta.flags.concurrencyFieldUsed = true;
}

setTimeout(() => {
if (!op.__.meta.flags.concurrencyOperatorUsed) {
console.error(
'Please apply concurrency operator to the query, read more: https://farfetched.pages.dev/adr/concurrency'
);

concurrency(op, {
strategy: config.concurrency?.strategy ?? 'TAKE_LATEST',
abortAll: config.concurrency?.abort,
Expand Down

0 comments on commit 121de27

Please sign in to comment.