@@ -37,24 +37,24 @@ artwork's artist - using the dataloader pattern that call would only happen once
37
37
38
38
Our usage has a few moving parts:
39
39
40
- * The ` api ` object: for example [ ` /lib/apis/gravity.js ` ] [ api_grav ] - it is a wrapper around [ fetch] [ fetch ] that
40
+ - The ` api ` object: for example [ ` /lib/apis/gravity.js ` ] [ api_grav ] - it is a wrapper around [ fetch] [ fetch ] that
41
41
customizes the request to the service. The params tend to differ depending on the authentication method for that
42
42
server.
43
43
44
- * The ` loader factory ` - there are three loader factories. They all end up exposing the same API, so your tests should
44
+ - The ` loader factory ` - there are three loader factories. They all end up exposing the same API, so your tests should
45
45
be the same shape regardless of the servers or types of calls you need to make.
46
46
47
47
When an unauthenticated API call is made we take the result and store it in memcache, then the next time (potentially
48
48
on another user's request) the cached result is passed back and we update memcache for the next request.
49
49
50
- * [ ` loader_without_authentication_factory ` ] [ no_auth_loader ] for API requests which can call the ` api ` directly and be
50
+ - [ ` loader_without_authentication_factory ` ] [ no_auth_loader ] for API requests which can call the ` api ` directly and be
51
51
safely cached in memcache.
52
- * [ ` loader_with_authentication_factory ` ] [ auth_loader ] for API requests that _ could_ require a call for an
52
+ - [ ` loader_with_authentication_factory ` ] [ auth_loader ] for API requests that _ could_ require a call for an
53
53
authentication token (like the examples in [ Adding a New Microservice] [ new_micro ] .)
54
- * [ ` loader_one_off_factory ` ] [ one_off_loader ] for API requests which have custom auth schemes, or need to ignore cache
54
+ - [ ` loader_one_off_factory ` ] [ one_off_loader ] for API requests which have custom auth schemes, or need to ignore cache
55
55
completely.
56
56
57
- * The ` loader ` themselves. These are a set of functions which [ are exposed] [ loaders ] as properties on the root object
57
+ - The ` loader ` themselves. These are a set of functions which [ are exposed] [ loaders ] as properties on the root object
58
58
during the resolving stages of our graphQL implementation.
59
59
60
60
``` js
@@ -92,17 +92,17 @@ Our usage has a few moving parts:
92
92
},
93
93
}),
94
94
95
- resolve : (artist , options , request , { rootValue: { artistArtworksLoader } }) => {
95
+ resolve: async (artist , options , request , { rootValue: { artistArtworksLoader } }) => {
96
96
const { limit: size , offset } = getPagingParameters (options)
97
97
const { sort , filter , published } = options
98
98
99
99
const gravityArgs = { size, offset, sort, filter, published }
100
- return artistArtworksLoader (artist .id , gravityArgs). then ( artworks =>
101
- connectionFromArraySlice (artworks, options, {
102
- arrayLength : artistArtworkArrayLength (artist, filter),
103
- sliceStart : offset ,
104
- })
105
- )
100
+ const artworks = await artistArtworksLoader (artist .id , gravityArgs)
101
+
102
+ return connectionFromArraySlice (artworks, options, {
103
+ arrayLength : artistArtworkArrayLength (artist, filter) ,
104
+ sliceStart : offset,
105
+ } )
106
106
},
107
107
},
108
108
// [...]
0 commit comments