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