Skip to content

Commit

Permalink
fixes and improvements (#206)
Browse files Browse the repository at this point in the history
* Squashed 'examples/cra/' content from commit 0c702ff

git-subtree-dir: examples/cra
git-subtree-split: 0c702ff78c75ddf4df6f3cd32c520899ecdd82b2

* add cra example from codesandbox

* fix args state usePaginatedQuery

* disable config file write if no cli usage

 fixes #203

* [core] divide subscriptions with only one top level field

closes #190

* test multiple subs & handle multi unsubscribe

* [react] fix useQuery's prepare update

* [react] detach react default retry in useMutation

* [cli] allow introspection json without "data" field

* update deps

* update deps
  • Loading branch information
PabloSzx authored Apr 21, 2021
1 parent 972453e commit 4a3d5ef
Show file tree
Hide file tree
Showing 93 changed files with 6,882 additions and 3,935 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-pots-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gqless': patch
---

divide subscriptions with only one top level field
8 changes: 7 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": ["mercurius-example", "react-example", "website", "github-example"]
"ignore": [
"mercurius-example",
"react-example",
"website",
"github-example",
"cra-example"
]
}
5 changes: 5 additions & 0 deletions .changeset/dry-ants-rescue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gqless/cli': patch
---

allow introspection json without "data" field
5 changes: 5 additions & 0 deletions .changeset/dry-windows-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gqless/react': patch
---

fix useQuery's prepare update
5 changes: 5 additions & 0 deletions .changeset/grumpy-teachers-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gqless/cli': patch
---

disable config file write if no cli usage
5 changes: 5 additions & 0 deletions .changeset/rude-laws-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gqless/react': patch
---

fix args state usePaginatedQuery
5 changes: 5 additions & 0 deletions .changeset/three-trees-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gqless/react': patch
---

detach react default retry in useMutation
14 changes: 7 additions & 7 deletions docs/client/api/classes/gqlesserror.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Defined in: [packages/gqless/src/Error/index.ts:4](https://github.com/gqless/gql

Inherited from: Error.message

Defined in: node_modules/.pnpm/typescript@4.2.3/node_modules/typescript/lib/lib.es5.d.ts:974
Defined in: node_modules/.pnpm/typescript@4.2.4/node_modules/typescript/lib/lib.es5.d.ts:974

---

Expand All @@ -62,7 +62,7 @@ Defined in: node_modules/.pnpm/typescript@4.2.3/node_modules/typescript/lib/lib.

Inherited from: Error.name

Defined in: node_modules/.pnpm/typescript@4.2.3/node_modules/typescript/lib/lib.es5.d.ts:973
Defined in: node_modules/.pnpm/typescript@4.2.4/node_modules/typescript/lib/lib.es5.d.ts:973

---

Expand All @@ -80,7 +80,7 @@ Defined in: [packages/gqless/src/Error/index.ts:5](https://github.com/gqless/gql

Inherited from: Error.stack

Defined in: node_modules/.pnpm/typescript@4.2.3/node_modules/typescript/lib/lib.es5.d.ts:975
Defined in: node_modules/.pnpm/typescript@4.2.4/node_modules/typescript/lib/lib.es5.d.ts:975

---

Expand All @@ -105,11 +105,11 @@ Optional override for formatting stack traces

**Returns:** _any_

Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/globals.d.ts:11
Defined in: node_modules/.pnpm/@types+node@14.14.41/node_modules/@types/node/globals.d.ts:11

Inherited from: Error.prepareStackTrace

Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/globals.d.ts:11
Defined in: node_modules/.pnpm/@types+node@14.14.41/node_modules/@types/node/globals.d.ts:11

---

Expand All @@ -119,7 +119,7 @@ Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/glo

Inherited from: Error.stackTraceLimit

Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/globals.d.ts:13
Defined in: node_modules/.pnpm/@types+node@14.14.41/node_modules/@types/node/globals.d.ts:13

## Methods

Expand Down Expand Up @@ -156,7 +156,7 @@ Create .stack property on a target object

Inherited from: Error.captureStackTrace

Defined in: node_modules/.pnpm/@types+node@14.14.37/node_modules/@types/node/globals.d.ts:4
Defined in: node_modules/.pnpm/@types+node@14.14.41/node_modules/@types/node/globals.d.ts:4

---

Expand Down
6 changes: 3 additions & 3 deletions docs/client/api/interfaces/accessorcache.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ hide_title: true

### addAccessorChild

**addAccessorChild**: (`parent`: ProxyAccessor, `child`: _null_ \| ProxyAccessor) => _void_
**addAccessorChild**: (`parent`: ProxyAccessor, `child`: `null` \| ProxyAccessor) => _void_

#### Type declaration:

▸ (`parent`: ProxyAccessor, `child`: _null_ \| ProxyAccessor): _void_
▸ (`parent`: ProxyAccessor, `child`: `null` \| ProxyAccessor): _void_

#### Parameters:

| Name | Type |
| :------- | :---------------------- |
| `parent` | ProxyAccessor |
| `child` | _null_ \| ProxyAccessor |
| `child` | `null` \| ProxyAccessor |

**Returns:** _void_

Expand Down
6 changes: 3 additions & 3 deletions docs/client/api/interfaces/assignselections.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hide_title: true

## Callable

**AssignSelections**<A, B\>(`source`: _undefined_ \| _null_ \| A, `target`: _undefined_ \| _null_ \| B): _void_
**AssignSelections**<A, B\>(`source`: _undefined_ \| `null` \| A, `target`: _undefined_ \| `null` \| B): _void_

#### Type parameters:

Expand All @@ -23,8 +23,8 @@ hide_title: true

| Name | Type |
| :------- | :------------------------- |
| `source` | _undefined_ \| _null_ \| A |
| `target` | _undefined_ \| _null_ \| B |
| `source` | _undefined_ \| `null` \| A |
| `target` | _undefined_ \| `null` \| B |

**Returns:** _void_

Expand Down
6 changes: 3 additions & 3 deletions docs/client/api/interfaces/buildandfetchselections.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hide_title: true

## Callable

**BuildAndFetchSelections**<TData\>(`selections`: _undefined_ \| [_Selection_](../classes/selection.md)[], `type`: _query_ \| _mutation_, `cache?`: CacheInstance, `options?`: FetchResolveOptions, `lastTryParam?`: _boolean_): _Promise_<undefined \| _null_ \| TData\>
**BuildAndFetchSelections**<TData\>(`selections`: _undefined_ \| [_Selection_](../classes/selection.md)[], `type`: `"query"` \| `"mutation"`, `cache?`: CacheInstance, `options?`: FetchResolveOptions, `lastTryParam?`: _boolean_): _Promise_<undefined \| `null` \| TData\>

#### Type parameters:

Expand All @@ -23,11 +23,11 @@ hide_title: true
| Name | Type |
| :-------------- | :------------------------------------------------------ |
| `selections` | _undefined_ \| [_Selection_](../classes/selection.md)[] |
| `type` | _query_ \| _mutation_ |
| `type` | `"query"` \| `"mutation"` |
| `cache?` | CacheInstance |
| `options?` | FetchResolveOptions |
| `lastTryParam?` | _boolean_ |

**Returns:** _Promise_<undefined \| _null_ \| TData\>
**Returns:** _Promise_<undefined \| `null` \| TData\>

Defined in: [packages/gqless/src/Client/resolvers.ts:171](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Client/resolvers.ts#L171)
4 changes: 2 additions & 2 deletions docs/client/api/interfaces/buildselection.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ hide_title: true

## Callable

**BuildSelection**(`type`: _query_ \| _mutation_ \| _subscription_, ...`values`: [_BuildSelectionValue_](../modules.md#buildselectionvalue)[]): [_Selection_](../classes/selection.md)
**BuildSelection**(`type`: `"query"` \| `"mutation"` \| `"subscription"`, ...`values`: [_BuildSelectionValue_](../modules.md#buildselectionvalue)[]): [_Selection_](../classes/selection.md)

#### Parameters:

| Name | Type |
| :---------- | :----------------------------------------------------------- |
| `type` | _query_ \| _mutation_ \| _subscription_ |
| `type` | `"query"` \| `"mutation"` \| `"subscription"` |
| `...values` | [_BuildSelectionValue_](../modules.md#buildselectionvalue)[] |

**Returns:** [_Selection_](../classes/selection.md)
Expand Down
10 changes: 5 additions & 5 deletions docs/client/api/interfaces/gqlessclient.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Defined in: [packages/gqless/src/Client/client.ts:176](https://github.com/gqless

### mutation

**mutation**: GeneratedSchema[*mutation*]
**mutation**: GeneratedSchema[``"mutation"``]

Defined in: [packages/gqless/src/Client/client.ts:161](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Client/client.ts#L161)

Expand All @@ -131,7 +131,7 @@ Defined in: [packages/gqless/src/Client/client.ts:174](https://github.com/gqless

### query

**query**: GeneratedSchema[*query*]
**query**: GeneratedSchema[``"query"``]

Defined in: [packages/gqless/src/Client/client.ts:160](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Client/client.ts#L160)

Expand Down Expand Up @@ -171,7 +171,7 @@ Defined in: [packages/gqless/src/Client/client.ts:172](https://github.com/gqless

### subscription

**subscription**: GeneratedSchema[*subscription*]
**subscription**: GeneratedSchema[``"subscription"``]

Defined in: [packages/gqless/src/Client/client.ts:162](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Client/client.ts#L162)

Expand Down Expand Up @@ -220,13 +220,13 @@ Inherited from: PersistenceHelpers.restorePersistence

Defined in: [packages/gqless/src/Cache/persistence.ts:11](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Cache/persistence.ts#L11)

**restorePersistence**(`backup`: _undefined_ \| _null_ \| _string_, `expectedVersion?`: _string_): _boolean_
**restorePersistence**(`backup`: _undefined_ \| `null` \| _string_, `expectedVersion?`: _string_): _boolean_

#### Parameters:

| Name | Type |
| :----------------- | :-------------------------------- |
| `backup` | _undefined_ \| _null_ \| _string_ |
| `backup` | _undefined_ \| `null` \| _string_ |
| `expectedVersion?` | _string_ |

**Returns:** _boolean_
Expand Down
4 changes: 2 additions & 2 deletions docs/client/api/interfaces/mutate.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ hide_title: true

## Callable

**Mutate**<T\>(`fn`: (`mutation`: GeneratedSchema[*mutation*]) => T, `opts?`: { `onComplete?`: (`data`: T, `helpers`: [_MutateHelpers_](mutatehelpers.md)<GeneratedSchema\>) => _void_ ; `onError?`: (`error`: [_GQlessError_](../classes/gqlesserror.md), `helpers`: [_MutateHelpers_](mutatehelpers.md)<GeneratedSchema\>) => _void_ }): _Promise_<T\>
**Mutate**<T\>(`fn`: (`mutation`: GeneratedSchema[``"mutation"``]) => T, `opts?`: { `onComplete?`: (`data`: T, `helpers`: [_MutateHelpers_](mutatehelpers.md)<GeneratedSchema\>) => _void_ ; `onError?`: (`error`: [_GQlessError_](../classes/gqlesserror.md), `helpers`: [_MutateHelpers_](mutatehelpers.md)<GeneratedSchema\>) => _void_ }): _Promise_<T\>

#### Type parameters:

Expand All @@ -30,7 +30,7 @@ hide_title: true

| Name | Type |
| :----------------- | :-------------------------------------------------------------------------------------------------------------------------------- |
| `fn` | (`mutation`: GeneratedSchema[*mutation*]) => T |
| `fn` | (`mutation`: GeneratedSchema[``"mutation"``]) => T |
| `opts?` | _object_ |
| `opts.onComplete?` | (`data`: T, `helpers`: [_MutateHelpers_](mutatehelpers.md)<GeneratedSchema\>) => _void_ |
| `opts.onError?` | (`error`: [_GQlessError_](../classes/gqlesserror.md), `helpers`: [_MutateHelpers_](mutatehelpers.md)<GeneratedSchema\>) => _void_ |
Expand Down
2 changes: 1 addition & 1 deletion docs/client/api/interfaces/mutatehelpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Defined in: [packages/gqless/src/Client/client.ts:132](https://github.com/gqless

### query

**query**: GeneratedSchema[*query*]
**query**: GeneratedSchema[``"query"``]

Defined in: [packages/gqless/src/Client/client.ts:130](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Client/client.ts#L130)

Expand Down
8 changes: 4 additions & 4 deletions docs/client/api/interfaces/prefetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hide_title: true

## Callable

**Prefetch**<TData\>(`fn`: (`query`: GeneratedSchema[*query*]) => TData): TData \| _Promise_<TData\> & { `schedulerPromise`: _Promise_<SchedulerPromiseValue\> }
**Prefetch**<TData\>(`fn`: (`query`: GeneratedSchema[``"query"``]) => TData): TData \| _Promise_<TData\> & { `schedulerPromise`: _Promise_<SchedulerPromiseValue\> }

#### Type parameters:

Expand All @@ -27,9 +27,9 @@ hide_title: true

#### Parameters:

| Name | Type |
| :--- | :------------------------------------------- |
| `fn` | (`query`: GeneratedSchema[*query*]) => TData |
| Name | Type |
| :--- | :----------------------------------------------- |
| `fn` | (`query`: GeneratedSchema[``"query"``]) => TData |

**Returns:** TData \| _Promise_<TData\> & { `schedulerPromise`: _Promise_<SchedulerPromiseValue\> }

Expand Down
10 changes: 5 additions & 5 deletions docs/client/api/interfaces/resolveoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,19 @@ Defined in: [packages/gqless/src/Client/resolvers.ts:53](https://github.com/gqle

### onSubscription

`Optional` **onSubscription**: (`event`: { `data`: TData ; `error?`: _undefined_ ; `type`: _data_ ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: TData ; `error`: [_GQlessError_](../classes/gqlesserror.md) ; `type`: _with-errors_ ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: _undefined_ ; `error?`: _undefined_ ; `type`: _start_ \| _complete_ ; `unsubscribe`: () => _Promise_<void\> }) => _void_
`Optional` **onSubscription**: (`event`: { `data`: TData ; `error?`: _undefined_ ; `type`: `"data"` ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: TData ; `error`: [_GQlessError_](../classes/gqlesserror.md) ; `type`: `"with-errors"` ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: _undefined_ ; `error?`: _undefined_ ; `type`: `"start"` \| `"complete"` ; `unsubscribe`: () => _Promise_<void\> }) => _void_

On subscription event listener

#### Type declaration:

▸ (`event`: { `data`: TData ; `error?`: _undefined_ ; `type`: _data_ ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: TData ; `error`: [_GQlessError_](../classes/gqlesserror.md) ; `type`: _with-errors_ ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: _undefined_ ; `error?`: _undefined_ ; `type`: _start_ \| _complete_ ; `unsubscribe`: () => _Promise_<void\> }): _void_
▸ (`event`: { `data`: TData ; `error?`: _undefined_ ; `type`: `"data"` ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: TData ; `error`: [_GQlessError_](../classes/gqlesserror.md) ; `type`: `"with-errors"` ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: _undefined_ ; `error?`: _undefined_ ; `type`: `"start"` \| `"complete"` ; `unsubscribe`: () => _Promise_<void\> }): _void_

#### Parameters:

| Name | Type |
| :------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `event` | { `data`: TData ; `error?`: _undefined_ ; `type`: _data_ ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: TData ; `error`: [_GQlessError_](../classes/gqlesserror.md) ; `type`: _with-errors_ ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: _undefined_ ; `error?`: _undefined_ ; `type`: _start_ \| _complete_ ; `unsubscribe`: () => _Promise_<void\> } |
| Name | Type |
| :------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `event` | { `data`: TData ; `error?`: _undefined_ ; `type`: `"data"` ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: TData ; `error`: [_GQlessError_](../classes/gqlesserror.md) ; `type`: `"with-errors"` ; `unsubscribe`: () => _Promise_<void\> } \| { `data?`: _undefined_ ; `error?`: _undefined_ ; `type`: `"start"` \| `"complete"` ; `unsubscribe`: () => _Promise_<void\> } |

**Returns:** _void_

Expand Down
2 changes: 1 addition & 1 deletion docs/client/api/interfaces/scheduler.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Defined in: [packages/gqless/src/Scheduler/index.ts:58](https://github.com/gqles

### resolving

**resolving**: _null_ \| _DeferredPromise_<SchedulerPromiseValue\>
**resolving**: `null` \| _DeferredPromise_<SchedulerPromiseValue\>

Defined in: [packages/gqless/src/Scheduler/index.ts:38](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Scheduler/index.ts#L38)

Expand Down
10 changes: 5 additions & 5 deletions docs/client/api/interfaces/setcache.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ hide_title: true

Defined in: [packages/gqless/src/Accessor/index.ts:119](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Accessor/index.ts#L119)

**SetCache**<A\>(`accessor`: A, `data`: _undefined_ \| _null_ \| [_DeepPartial_](../modules.md#deeppartial)<A\>): _void_
**SetCache**<A\>(`accessor`: A, `data`: _undefined_ \| `null` \| [_DeepPartial_](../modules.md#deeppartial)<A\>): _void_

#### Type parameters:

Expand All @@ -36,13 +36,13 @@ Defined in: [packages/gqless/src/Accessor/index.ts:119](https://github.com/gqles
| Name | Type |
| :--------- | :---------------------------------------------------------------------- |
| `accessor` | A |
| `data` | _undefined_ \| _null_ \| [_DeepPartial_](../modules.md#deeppartial)<A\> |
| `data` | _undefined_ \| `null` \| [_DeepPartial_](../modules.md#deeppartial)<A\> |

**Returns:** _void_

Defined in: [packages/gqless/src/Accessor/index.ts:120](https://github.com/gqless/gqless/blob/master/packages/gqless/src/Accessor/index.ts#L120)

**SetCache**<B\>(`accessor`: B, `args`: _Parameters_<B\>[*0*], `data`: _undefined_ \| _null_ \| [_DeepPartial_](../modules.md#deeppartial)<ReturnType<B\>\>): _void_
**SetCache**<B\>(`accessor`: B, `args`: _Parameters_<B\>[``"0"``], `data`: _undefined_ \| `null` \| [_DeepPartial_](../modules.md#deeppartial)<ReturnType<B\>\>): _void_

#### Type parameters:

Expand All @@ -55,8 +55,8 @@ Defined in: [packages/gqless/src/Accessor/index.ts:120](https://github.com/gqles
| Name | Type |
| :--------- | :----------------------------------------------------------------------------------- |
| `accessor` | B |
| `args` | _Parameters_<B\>[*0*] |
| `data` | _undefined_ \| _null_ \| [_DeepPartial_](../modules.md#deeppartial)<ReturnType<B\>\> |
| `args` | _Parameters_<B\>[``"0"``] |
| `data` | _undefined_ \| `null` \| [_DeepPartial_](../modules.md#deeppartial)<ReturnType<B\>\> |

**Returns:** _void_

Expand Down
6 changes: 3 additions & 3 deletions docs/client/api/interfaces/subscribeevents.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ Defined in: [packages/gqless/src/Client/client.ts:67](https://github.com/gqless/

### onError

**onError**: (`payload`: { `data`: _null_ \| _Record_<string, unknown\> ; `error`: [_GQlessError_](../classes/gqlesserror.md) }) => _void_
**onError**: (`payload`: { `data`: `null` \| _Record_<string, unknown\> ; `error`: [_GQlessError_](../classes/gqlesserror.md) }) => _void_

#### Type declaration:

▸ (`payload`: { `data`: _null_ \| _Record_<string, unknown\> ; `error`: [_GQlessError_](../classes/gqlesserror.md) }): _void_
▸ (`payload`: { `data`: `null` \| _Record_<string, unknown\> ; `error`: [_GQlessError_](../classes/gqlesserror.md) }): _void_

#### Parameters:

| Name | Type |
| :-------------- | :----------------------------------------- |
| `payload` | _object_ |
| `payload.data` | _null_ \| _Record_<string, unknown\> |
| `payload.data` | `null` \| _Record_<string, unknown\> |
| `payload.error` | [_GQlessError_](../classes/gqlesserror.md) |

**Returns:** _void_
Expand Down
Loading

1 comment on commit 4a3d5ef

@vercel
Copy link

@vercel vercel bot commented on 4a3d5ef Apr 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.