@envelop/apollo-datasources 2.0.0-alpha-d0d0776.0 → 2.0.0-alpha-ccec0fc.0

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 CHANGED
@@ -11,26 +11,26 @@ yarn add @envelop/apollo-datasources
11
11
  ## Usage Example
12
12
 
13
13
  ```ts
14
- import { envelop } from '@envelop/core';
15
- import { useApolloDataSources } from '@envelop/apollo-datasources';
16
- import { RESTDataSource } from 'apollo-datasource-rest';
14
+ import { envelop } from '@envelop/core'
15
+ import { useApolloDataSources } from '@envelop/apollo-datasources'
16
+ import { RESTDataSource } from 'apollo-datasource-rest'
17
17
 
18
18
  class MoviesAPI extends RESTDataSource {
19
19
  constructor() {
20
- super();
21
- this.baseURL = 'https://movies-api.example.com/';
20
+ super()
21
+ this.baseURL = 'https://movies-api.example.com/'
22
22
  }
23
23
 
24
24
  async getMovie(id) {
25
- return this.get(`movies/${encodeURIComponent(id)}`);
25
+ return this.get(`movies/${encodeURIComponent(id)}`)
26
26
  }
27
27
 
28
28
  async getMostViewedMovies(limit = 10) {
29
29
  const data = await this.get('movies', {
30
30
  per_page: limit,
31
- order_by: 'most_viewed',
32
- });
33
- return data.results;
31
+ order_by: 'most_viewed'
32
+ })
33
+ return data.results
34
34
  }
35
35
  }
36
36
 
@@ -40,12 +40,12 @@ const getEnveloped = envelop({
40
40
  useApolloDataSources({
41
41
  dataSources() {
42
42
  return {
43
- moviesAPI: new MoviesAPI(),
44
- };
45
- },
43
+ moviesAPI: new MoviesAPI()
44
+ }
45
+ }
46
46
  // To provide a custom cache, you can use the following code (InMemoryLRUCache is used by default):
47
47
  // cache: new YourCustomCache()
48
- }),
49
- ],
50
- });
48
+ })
49
+ ]
50
+ })
51
51
  ```
@@ -1,11 +1,9 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const apolloServerCaching = require('apollo-server-caching');
6
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useApolloDataSources = void 0;
4
+ const apollo_server_caching_1 = require("apollo-server-caching");
7
5
  function useApolloDataSources(config) {
8
- const cache = config.cache || new apolloServerCaching.InMemoryLRUCache();
6
+ const cache = config.cache || new apollo_server_caching_1.InMemoryLRUCache();
9
7
  return {
10
8
  async onExecute({ extendContext, args }) {
11
9
  const dataSources = config.dataSources();
@@ -28,5 +26,4 @@ function useApolloDataSources(config) {
28
26
  },
29
27
  };
30
28
  }
31
-
32
29
  exports.useApolloDataSources = useApolloDataSources;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,6 +1,5 @@
1
1
  import { InMemoryLRUCache } from 'apollo-server-caching';
2
-
3
- function useApolloDataSources(config) {
2
+ export function useApolloDataSources(config) {
4
3
  const cache = config.cache || new InMemoryLRUCache();
5
4
  return {
6
5
  async onExecute({ extendContext, args }) {
@@ -24,5 +23,3 @@ function useApolloDataSources(config) {
24
23
  },
25
24
  };
26
25
  }
27
-
28
- export { useApolloDataSources };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@envelop/apollo-datasources",
3
- "version": "2.0.0-alpha-d0d0776.0",
3
+ "version": "2.0.0-alpha-ccec0fc.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@envelop/core": "3.0.0-alpha-d0d0776.0",
6
+ "@envelop/core": "3.0.0-alpha-ccec0fc.0",
7
7
  "apollo-datasource": "^3",
8
8
  "apollo-server-caching": "^3",
9
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
9
+ "@graphql-tools/graphql": "0.1.0-alpha-e7752ba5.0"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -15,33 +15,42 @@
15
15
  },
16
16
  "author": "Kamil Kisiela <kamil.kisiela@gmail.com>",
17
17
  "license": "MIT",
18
- "main": "index.js",
19
- "module": "index.mjs",
20
- "typings": "index.d.ts",
18
+ "main": "cjs/index.js",
19
+ "module": "esm/index.js",
20
+ "typings": "typings/index.d.ts",
21
21
  "typescript": {
22
- "definition": "index.d.ts"
22
+ "definition": "typings/index.d.ts"
23
23
  },
24
+ "type": "module",
24
25
  "exports": {
25
26
  ".": {
26
27
  "require": {
27
- "default": "./index.js",
28
- "types": "./index.d.ts"
28
+ "types": "./typings/index.d.ts",
29
+ "default": "./cjs/index.js"
29
30
  },
30
31
  "import": {
31
- "default": "./index.mjs",
32
- "types": "./index.d.ts"
32
+ "types": "./typings/index.d.ts",
33
+ "default": "./esm/index.js"
34
+ },
35
+ "default": {
36
+ "types": "./typings/index.d.ts",
37
+ "default": "./esm/index.js"
33
38
  }
34
39
  },
35
40
  "./*": {
36
41
  "require": {
37
- "default": "./*.js",
38
- "types": "./*.d.ts"
42
+ "types": "./typings/*.d.ts",
43
+ "default": "./cjs/*.js"
39
44
  },
40
45
  "import": {
41
- "default": "./*.mjs",
42
- "types": "./*.d.ts"
46
+ "types": "./typings/*.d.ts",
47
+ "default": "./esm/*.js"
48
+ },
49
+ "default": {
50
+ "types": "./typings/*.d.ts",
51
+ "default": "./esm/*.js"
43
52
  }
44
53
  },
45
54
  "./package.json": "./package.json"
46
55
  }
47
- }
56
+ }
File without changes