@envelop/apollo-datasources 1.1.0 → 1.1.1-alpha-88024a80.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 +15 -15
- package/package.json +2 -2
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
|
```
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/apollo-datasources",
|
|
3
|
-
"version": "1.1.0",
|
|
3
|
+
"version": "1.1.1-alpha-88024a80.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "
|
|
6
|
+
"@envelop/core": "2.4.1-alpha-88024a80.0",
|
|
7
7
|
"apollo-datasource": "^3",
|
|
8
8
|
"apollo-server-caching": "^3",
|
|
9
9
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|