@rxdi/graphql-client 0.7.210 → 0.7.212

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.
@@ -1,5 +1,5 @@
1
- import { PossibleTypesMap } from '@apollo/client/core';
2
- export declare function importQuery<T>(search: T): any;
1
+ import { DocumentNode, PossibleTypesMap, TypedDocumentNode } from '@apollo/client/core';
2
+ export declare function importQuery<T extends string>(search: T): DocumentNode | TypedDocumentNode;
3
3
  export interface IntrospectionQuery {
4
4
  __schema: {
5
5
  types: {
@@ -3,19 +3,13 @@ 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_injection_1 = require("./graphql.injection");
6
7
  function importQuery(search) {
7
- let result;
8
- const DOCUMENTS = core_1.Container.get('graphql-documents');
9
- Object.keys(DOCUMENTS).filter((doc) => {
10
- if (doc.indexOf(search) !== -1) {
11
- result = DOCUMENTS[doc];
12
- }
13
- });
14
- if (!result) {
15
- console.error(`Missing query: ${search}`);
16
- return search;
8
+ const DOCUMENTS = core_1.Container.get(graphql_injection_1.GraphqlDocuments);
9
+ if (!DOCUMENTS[search]) {
10
+ throw new Error(`Missing query: ${search}`);
17
11
  }
18
- return result;
12
+ return DOCUMENTS[search];
19
13
  }
20
14
  const convertToPossibleTypes = (introspectionQuery) => introspectionQuery.__schema.types.reduce((acc, curr) => (Object.assign(Object.assign({}, acc), { [curr.name]: curr.possibleTypes.map((type) => type.name) })), {});
21
15
  exports.convertToPossibleTypes = convertToPossibleTypes;
@@ -1,10 +1,14 @@
1
1
  import { InjectionToken } from '@rxdi/core';
2
- import { ApolloClient as AC, ApolloClientOptions, RequestHandler } from '@apollo/client/core';
2
+ import { ApolloClient as AC, ApolloClientOptions, DocumentNode, RequestHandler, TypedDocumentNode } from '@apollo/client/core';
3
3
  import { NormalizedCacheObject, InMemoryCache } from '@apollo/client/cache';
4
4
  export declare const ApolloClient: InjectionToken<AC<NormalizedCacheObject>>;
5
5
  export interface ApolloClient extends AC<NormalizedCacheObject> {
6
6
  }
7
- export declare const GraphqlDocuments = "graphql-documents";
7
+ export declare const GraphqlDocuments: InjectionToken<Record<string, DocumentNode | TypedDocumentNode<{
8
+ [key: string]: any;
9
+ }, {
10
+ [key: string]: any;
11
+ }>>>;
8
12
  export interface GraphqlModuleConfig {
9
13
  uri: string;
10
14
  pubsub: string;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.noop = exports.noopHeaders = exports.GraphqlDocuments = exports.ApolloClient = void 0;
4
4
  const core_1 = require("@rxdi/core");
5
5
  exports.ApolloClient = new core_1.InjectionToken('apollo-link');
6
- exports.GraphqlDocuments = 'graphql-documents';
6
+ exports.GraphqlDocuments = new core_1.InjectionToken('graphql-documents');
7
7
  const noopHeaders = () => new Headers();
8
8
  exports.noopHeaders = noopHeaders;
9
9
  const noop = () => null;
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ let GraphqlModule = GraphqlModule_1 = class GraphqlModule {
48
48
  providers: [
49
49
  {
50
50
  provide: graphql_injection_1.GraphqlDocuments,
51
- useValue: documents,
51
+ useValue: Object.keys(documents).reduce((prev, doc) => (Object.assign(Object.assign({}, prev), { [doc.split('/').pop()]: documents[doc] })), {}),
52
52
  },
53
53
  {
54
54
  provide: graphql_injection_1.ApolloClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/graphql-client",
3
- "version": "0.7.210",
3
+ "version": "0.7.212",
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.209",
20
+ "@rxdi/core": "^0.7.211",
21
21
  "typescript": "^5.9.3",
22
22
  "graphql": "^16.12.0"
23
23
  },