File tree Expand file tree Collapse file tree 1 file changed +29
-12
lines changed
utils/website/graphile-config/plugin Expand file tree Collapse file tree 1 file changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -195,26 +195,30 @@ in the same resolved preset.
195
195
``` ts
196
196
export const MyPlugin: GraphileConfig .Plugin = {
197
197
name: " MyPlugin" ,
198
- // Plugins can have order constraints at the plugin level and at the
199
- // middleware level. All middleware in MyPlugin will be executed before any
200
- // middleware in plugins that have `provides: ["featureA" ]`
198
+ // Plugins can have default order constraints at the plugin level and can
199
+ // override them at the middleware level.
200
+ // This states that by default, middleware in MyPlugin will be executed
201
+ // before any other plugins' middleware that provides 'featureA'.
201
202
before: [" featureA" ],
202
203
libraryName: {
203
204
middleware: {
204
205
foo(next ) {
205
206
// ... do something
206
207
return next ();
207
208
},
209
+
208
210
bar: {
209
211
after: [" featureB" ],
210
- callback(next ) {
211
- // ... do something
212
- // Will be executed after middleware that set
213
- // `provides: ['featureB']`
214
- return next ();
212
+ async callback(next ) {
213
+ // Executed after middleware that provides 'featureB'
214
+ console .log (" MyPlugin" );
215
+ try {
216
+ return await next ();
217
+ } finally {
218
+ console .log (" /MyPlugin" );
219
+ }
215
220
},
216
221
},
217
- // ... any other middleware
218
222
},
219
223
},
220
224
};
@@ -225,14 +229,27 @@ export const OtherPlugin: GraphileConfig.Plugin = {
225
229
middleware: {
226
230
bar: {
227
231
provides: [" featureB" ],
228
- callback(next ) {
229
- // ... do something
230
- return next ();
232
+ async callback(next ) {
233
+ console .log (" OtherPlugin" );
234
+ try {
235
+ return await next ();
236
+ } finally {
237
+ console .log (" /OtherPlugin" );
238
+ }
231
239
},
232
240
},
233
241
},
234
242
},
235
243
};
244
+
245
+ /* Result of executing the `bar` action:
246
+
247
+ OtherPlugin
248
+ MyPlugin
249
+ /MyPlugin
250
+ /OtherPlugin
251
+
252
+ */
236
253
```
237
254
238
255
Similar to plugins' ` provides ` property, Graphile Config appends the plugin
You can’t perform that action at this time.
0 commit comments