@miurajs/miura-data-flow 0.0.2 → 0.0.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miurajs/miura-data-flow",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -1,5 +1,4 @@
1
1
  import { DataProvider, ProviderFactory } from './provider';
2
- import { request } from 'graphql-request'; // Example dependency
3
2
 
4
3
  export interface GraphQLProviderOptions {
5
4
  endpoint: string;
@@ -13,22 +12,17 @@ class GraphQLProvider<T> implements DataProvider<T> {
13
12
  this.options = options;
14
13
  }
15
14
 
15
+ private async _request(doc: string, variables?: any): Promise<any> {
16
+ const { request } = await import('graphql-request');
17
+ return request(this.options.endpoint, doc, variables, this.options.headers);
18
+ }
19
+
16
20
  async query(options: { query: string; variables?: any }): Promise<any> {
17
- return request(
18
- this.options.endpoint,
19
- options.query,
20
- options.variables,
21
- this.options.headers
22
- );
21
+ return this._request(options.query, options.variables);
23
22
  }
24
23
 
25
24
  async mutate(options: { mutation: string; variables?: any }): Promise<any> {
26
- return request(
27
- this.options.endpoint,
28
- options.mutation,
29
- options.variables,
30
- this.options.headers
31
- );
25
+ return this._request(options.mutation, options.variables);
32
26
  }
33
27
  }
34
28