@rxdi/graphql-client 0.7.256 → 0.7.258
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/dist/graphq.helpers.d.ts +8 -0
- package/dist/graphq.helpers.js +17 -2
- package/dist/graphql.injection.d.ts +3 -1
- package/dist/graphql.injection.js +2 -0
- package/dist/index.d.ts +2 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -55,6 +55,21 @@ gapi schema introspect --collect-documents --collect-types
|
|
|
55
55
|
|
|
56
56
|
More information can be found [HERE](https://github.com/Stradivario/gapi-cli/wiki/schema)
|
|
57
57
|
|
|
58
|
+
### Documents as text (smaller bundles)
|
|
59
|
+
|
|
60
|
+
`DOCUMENTS` may hold each document's **text** instead of a pre-parsed
|
|
61
|
+
syntax tree. Generate it with `--documents-as-text` (`@gapi/cli` 1.8.263+):
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
gapi schema collect --collect-types --documents-as-text
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`importQuery` parses a text document the first time it is asked for
|
|
68
|
+
(without source locations) and keeps the parsed node, so every later call
|
|
69
|
+
returns the same object. Pre-parsed trees carry a `loc` on every node and
|
|
70
|
+
are typically ~10x larger: in one app 389 documents were 2.27 MB as trees
|
|
71
|
+
and 0.22 MB as text.
|
|
72
|
+
|
|
58
73
|
# ApolloClientOptions interface
|
|
59
74
|
|
|
60
75
|
```ts
|
package/dist/graphq.helpers.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { DocumentNode, PossibleTypesMap, TypedDocumentNode } from '@apollo/client/core';
|
|
2
|
+
/**
|
|
3
|
+
* A document by file name. Documents may be registered as parsed
|
|
4
|
+
* DocumentNodes OR as their text (`gapi schema collect --documents-as-text`):
|
|
5
|
+
* a text document is parsed the first time it is asked for (without source
|
|
6
|
+
* locations) and the parsed node replaces it, so every later call returns
|
|
7
|
+
* the SAME object - Apollo keys its caches by document identity. Shipping
|
|
8
|
+
* text instead of pre-parsed trees cut a real app's first bundle by 1.7 MB.
|
|
9
|
+
*/
|
|
2
10
|
export declare function importQuery<T extends string>(search: T): DocumentNode | TypedDocumentNode;
|
|
3
11
|
export interface IntrospectionQuery {
|
|
4
12
|
__schema: {
|
package/dist/graphq.helpers.js
CHANGED
|
@@ -3,13 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.deepCopy = exports.convertToPossibleTypes = void 0;
|
|
4
4
|
exports.importQuery = importQuery;
|
|
5
5
|
const core_1 = require("@rxdi/core");
|
|
6
|
+
const graphql_1 = require("graphql");
|
|
6
7
|
const graphql_injection_1 = require("./graphql.injection");
|
|
8
|
+
/**
|
|
9
|
+
* A document by file name. Documents may be registered as parsed
|
|
10
|
+
* DocumentNodes OR as their text (`gapi schema collect --documents-as-text`):
|
|
11
|
+
* a text document is parsed the first time it is asked for (without source
|
|
12
|
+
* locations) and the parsed node replaces it, so every later call returns
|
|
13
|
+
* the SAME object - Apollo keys its caches by document identity. Shipping
|
|
14
|
+
* text instead of pre-parsed trees cut a real app's first bundle by 1.7 MB.
|
|
15
|
+
*/
|
|
7
16
|
function importQuery(search) {
|
|
8
17
|
const DOCUMENTS = core_1.Container.get(graphql_injection_1.GraphqlDocuments);
|
|
9
|
-
|
|
18
|
+
const document = DOCUMENTS[search];
|
|
19
|
+
if (!document) {
|
|
10
20
|
throw new Error(`Missing query: ${search}`);
|
|
11
21
|
}
|
|
12
|
-
|
|
22
|
+
if (typeof document === 'string') {
|
|
23
|
+
const parsed = (0, graphql_1.parse)(document, { noLocation: true });
|
|
24
|
+
DOCUMENTS[search] = parsed;
|
|
25
|
+
return parsed;
|
|
26
|
+
}
|
|
27
|
+
return document;
|
|
13
28
|
}
|
|
14
29
|
const convertToPossibleTypes = (introspectionQuery) => introspectionQuery.__schema.types.reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr.name]: curr.possibleTypes.map((type) => type.name) })), {});
|
|
15
30
|
exports.convertToPossibleTypes = convertToPossibleTypes;
|
|
@@ -32,7 +32,9 @@ export interface ApolloClient extends AC<NormalizedCacheObject> {
|
|
|
32
32
|
export declare const GraphqlSubscriptionClient: InjectionToken<ManagedSubscriptionClient>;
|
|
33
33
|
export interface GraphqlSubscriptionClient extends ManagedSubscriptionClient {
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/** Documents by file name: parsed, or their text (parsed on first use by
|
|
36
|
+
importQuery). */
|
|
37
|
+
export declare const GraphqlDocuments: InjectionToken<Record<string, string | DocumentNode | TypedDocumentNode<{
|
|
36
38
|
[key: string]: any;
|
|
37
39
|
}, {
|
|
38
40
|
[key: string]: any;
|
|
@@ -28,6 +28,8 @@ exports.ApolloClient = new core_1.InjectionToken('apollo-link');
|
|
|
28
28
|
* make from `connectionCallback` — see `onSubscriptionConnectionError`.
|
|
29
29
|
*/
|
|
30
30
|
exports.GraphqlSubscriptionClient = new core_1.InjectionToken('graphql-subscription-client');
|
|
31
|
+
/** Documents by file name: parsed, or their text (parsed on first use by
|
|
32
|
+
importQuery). */
|
|
31
33
|
exports.GraphqlDocuments = new core_1.InjectionToken('graphql-documents');
|
|
32
34
|
/**
|
|
33
35
|
* True when a WebSocket `connection_error` payload is an authorization
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ModuleWithServices } from '@rxdi/core';
|
|
2
|
+
import type { DocumentNode } from '@apollo/client/core';
|
|
2
3
|
import { GraphqlModuleConfig } from './graphql.injection';
|
|
3
4
|
export declare class GraphqlModule {
|
|
4
|
-
static forRoot({ uri, pubsub, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, httpOptions, pubsubOptions, onSubscriptionConnectionError, }?: GraphqlModuleConfig, documents?:
|
|
5
|
+
static forRoot({ uri, pubsub, refreshOnUnauthenticated, onRequest, cache, apolloRequestHandler, cancelPendingRequests, apolloClientOptions, httpOptions, pubsubOptions, onSubscriptionConnectionError, }?: GraphqlModuleConfig, documents?: Record<string, DocumentNode | string>): ModuleWithServices;
|
|
5
6
|
}
|
|
6
7
|
export * from './graphql.injection';
|
|
7
8
|
export * from './subscription-client';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/graphql-client",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.258",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "Kristiyan Tachev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"subscriptions-transport-ws": "^0.9.19"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@rxdi/core": "^0.7.
|
|
20
|
+
"@rxdi/core": "^0.7.257",
|
|
21
21
|
"@types/jest": "^29.5.0",
|
|
22
22
|
"graphql": "^16.12.0",
|
|
23
23
|
"jest": "^29.7.0",
|