Skip to content

Commit a6af54c

Browse files
authored
enhance: Update getOptimisticResponse snapshot types to include getResponseMeta (#3417)
1 parent b75a480 commit a6af54c

File tree

6 files changed

+116
-0
lines changed

6 files changed

+116
-0
lines changed

.changeset/mean-hotels-attack.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@data-client/endpoint': patch
3+
'@data-client/graphql': patch
4+
'@data-client/rest': patch
5+
---
6+
7+
Update getOptimisticResponse snapshot types to include getResponseMeta

packages/endpoint/src/SnapshotInterface.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,39 @@ export interface SnapshotInterface {
3939
expiresAt: number;
4040
};
4141

42+
/**
43+
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
44+
* @see https://dataclient.io/docs/api/Snapshot#getResponseMeta
45+
*/
46+
getResponseMeta<E extends EndpointInterface>(
47+
endpoint: E,
48+
...args: readonly [null]
49+
): {
50+
data: DenormalizeNullable<E['schema']>;
51+
expiryStatus: ExpiryStatusInterface;
52+
expiresAt: number;
53+
};
54+
55+
getResponseMeta<E extends EndpointInterface>(
56+
endpoint: E,
57+
...args: readonly [...Parameters<E>]
58+
): {
59+
data: DenormalizeNullable<E['schema']>;
60+
expiryStatus: ExpiryStatusInterface;
61+
expiresAt: number;
62+
};
63+
64+
getResponseMeta<
65+
E extends Pick<EndpointInterface, 'key' | 'schema' | 'invalidIfStale'>,
66+
>(
67+
endpoint: E,
68+
...args: readonly [...Parameters<E['key']>] | readonly [null]
69+
): {
70+
data: DenormalizeNullable<E['schema']>;
71+
expiryStatus: ExpiryStatusInterface;
72+
expiresAt: number;
73+
};
74+
4275
/** @see https://dataclient.io/docs/api/Snapshot#getError */
4376
getError<E extends EndpointInterface>(
4477
endpoint: E,

website/src/components/Playground/editor-types/@data-client/endpoint.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ interface SnapshotInterface {
102102
expiryStatus: ExpiryStatusInterface;
103103
expiresAt: number;
104104
};
105+
/**
106+
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
107+
* @see https://dataclient.io/docs/api/Snapshot#getResponseMeta
108+
*/
109+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [null]): {
110+
data: DenormalizeNullable<E['schema']>;
111+
expiryStatus: ExpiryStatusInterface;
112+
expiresAt: number;
113+
};
114+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>]): {
115+
data: DenormalizeNullable<E['schema']>;
116+
expiryStatus: ExpiryStatusInterface;
117+
expiresAt: number;
118+
};
119+
getResponseMeta<E extends Pick<EndpointInterface, 'key' | 'schema' | 'invalidIfStale'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): {
120+
data: DenormalizeNullable<E['schema']>;
121+
expiryStatus: ExpiryStatusInterface;
122+
expiresAt: number;
123+
};
105124
/** @see https://dataclient.io/docs/api/Snapshot#getError */
106125
getError<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>] | readonly [null]): ErrorTypes | undefined;
107126
getError<E extends Pick<EndpointInterface, 'key'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): ErrorTypes | undefined;

website/src/components/Playground/editor-types/@data-client/graphql.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,25 @@ interface SnapshotInterface {
102102
expiryStatus: ExpiryStatusInterface;
103103
expiresAt: number;
104104
};
105+
/**
106+
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
107+
* @see https://dataclient.io/docs/api/Snapshot#getResponseMeta
108+
*/
109+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [null]): {
110+
data: DenormalizeNullable<E['schema']>;
111+
expiryStatus: ExpiryStatusInterface;
112+
expiresAt: number;
113+
};
114+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>]): {
115+
data: DenormalizeNullable<E['schema']>;
116+
expiryStatus: ExpiryStatusInterface;
117+
expiresAt: number;
118+
};
119+
getResponseMeta<E extends Pick<EndpointInterface, 'key' | 'schema' | 'invalidIfStale'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): {
120+
data: DenormalizeNullable<E['schema']>;
121+
expiryStatus: ExpiryStatusInterface;
122+
expiresAt: number;
123+
};
105124
/** @see https://dataclient.io/docs/api/Snapshot#getError */
106125
getError<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>] | readonly [null]): ErrorTypes | undefined;
107126
getError<E extends Pick<EndpointInterface, 'key'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): ErrorTypes | undefined;

website/src/components/Playground/editor-types/@data-client/rest.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,25 @@ interface SnapshotInterface {
104104
expiryStatus: ExpiryStatusInterface;
105105
expiresAt: number;
106106
};
107+
/**
108+
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
109+
* @see https://dataclient.io/docs/api/Snapshot#getResponseMeta
110+
*/
111+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [null]): {
112+
data: DenormalizeNullable<E['schema']>;
113+
expiryStatus: ExpiryStatusInterface;
114+
expiresAt: number;
115+
};
116+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>]): {
117+
data: DenormalizeNullable<E['schema']>;
118+
expiryStatus: ExpiryStatusInterface;
119+
expiresAt: number;
120+
};
121+
getResponseMeta<E extends Pick<EndpointInterface, 'key' | 'schema' | 'invalidIfStale'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): {
122+
data: DenormalizeNullable<E['schema']>;
123+
expiryStatus: ExpiryStatusInterface;
124+
expiresAt: number;
125+
};
107126
/** @see https://dataclient.io/docs/api/Snapshot#getError */
108127
getError<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>] | readonly [null]): ErrorTypes | undefined;
109128
getError<E extends Pick<EndpointInterface, 'key'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): ErrorTypes | undefined;

website/src/components/Playground/editor-types/globals.d.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,25 @@ interface SnapshotInterface {
108108
expiryStatus: ExpiryStatusInterface;
109109
expiresAt: number;
110110
};
111+
/**
112+
* Gets the (globally referentially stable) response for a given endpoint/args pair from state given.
113+
* @see https://dataclient.io/docs/api/Snapshot#getResponseMeta
114+
*/
115+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [null]): {
116+
data: DenormalizeNullable<E['schema']>;
117+
expiryStatus: ExpiryStatusInterface;
118+
expiresAt: number;
119+
};
120+
getResponseMeta<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>]): {
121+
data: DenormalizeNullable<E['schema']>;
122+
expiryStatus: ExpiryStatusInterface;
123+
expiresAt: number;
124+
};
125+
getResponseMeta<E extends Pick<EndpointInterface, 'key' | 'schema' | 'invalidIfStale'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): {
126+
data: DenormalizeNullable<E['schema']>;
127+
expiryStatus: ExpiryStatusInterface;
128+
expiresAt: number;
129+
};
111130
/** @see https://dataclient.io/docs/api/Snapshot#getError */
112131
getError<E extends EndpointInterface>(endpoint: E, ...args: readonly [...Parameters<E>] | readonly [null]): ErrorTypes$1 | undefined;
113132
getError<E extends Pick<EndpointInterface, 'key'>>(endpoint: E, ...args: readonly [...Parameters<E['key']>] | readonly [null]): ErrorTypes$1 | undefined;

0 commit comments

Comments
 (0)