@@ -645,7 +645,7 @@ function App() {
645
645
// every time we make an http request, this will run 1st before the request is made
646
646
// url, path and route are supplied to the interceptor
647
647
// request options can be modified and must be returned
648
- request: async (options , url , path , route ) => {
648
+ request: async ({ options, url, path, route } ) => {
649
649
if (isExpired (token)) {
650
650
token = await getNewToken ()
651
651
setToken (token)
@@ -654,7 +654,7 @@ function App() {
654
654
return options
655
655
},
656
656
// every time we make an http request, before getting the response back, this will run
657
- response: async (response ) => {
657
+ response: async ({ response } ) => {
658
658
// unfortunately, because this is a JS Response object, we have to modify it directly.
659
659
// It shouldn't have any negative affect since this is getting reset on each request.
660
660
const res = response
@@ -879,10 +879,10 @@ const options = {
879
879
880
880
// typically, `interceptors` would be added as an option to the `<Provider />`
881
881
interceptors: {
882
- request: async (options , url , path , route ) => { // `async` is not required
882
+ request: async ({ options, url, path, route } ) => { // `async` is not required
883
883
return options // returning the `options` is important
884
884
},
885
- response: async (response ) => {
885
+ response: async ({ response } ) => {
886
886
// note: `response.data` is equivalent to `await response.json()`
887
887
return response // returning the `response` is important
888
888
}
@@ -1057,12 +1057,6 @@ Todos
1057
1057
// I don't really like this solution though.
1058
1058
// Another solution is to only allow the `cache` option with the `<Provider cache={new Map()} />`
1059
1059
cache: new Map (),
1060
- interceptors: {
1061
- // I think it's more scalable/clean to have this as an object.
1062
- // What if we only need the `route` and `options`?
1063
- request: async ({ options, url, path, route }) => {},
1064
- response: async ({ response }) => {}
1065
- },
1066
1060
// these will be the exact same ones as Apollo's
1067
1061
cachePolicy: ' cache-and-network' , ' network-only' , ' cache-only' , ' no-cache' // 'cache-first'
1068
1062
// potential idea to fetch on server instead of just having `loading` state. Not sure if this is a good idea though
0 commit comments