@@ -42,6 +42,7 @@ const typeDefs = `
42
42
version: String!
43
43
config: InterceptionConfig!
44
44
interceptors: [Interceptor!]!
45
+ interceptor(id: ID!): Interceptor!
45
46
networkInterfaces: Json
46
47
}
47
48
@@ -67,12 +68,17 @@ const typeDefs = `
67
68
type Interceptor {
68
69
id: ID!
69
70
version: String!
70
- metadata: Json
71
+ metadata(type: MetadataType) : Json
71
72
72
73
isActivable: Boolean!
73
74
isActive(proxyPort: Int!): Boolean!
74
75
}
75
76
77
+ enum MetadataType {
78
+ SUMMARY,
79
+ DETAILED
80
+ }
81
+
76
82
scalar Json
77
83
scalar Error
78
84
scalar Void
@@ -101,6 +107,7 @@ const buildResolvers = (
101
107
Query : {
102
108
version : ( ) => packageJson . version ,
103
109
interceptors : ( ) => _ . values ( interceptors ) ,
110
+ interceptor : ( _ : any , { id } : { id : string } ) => interceptors [ id ] ,
104
111
config : ( ) => ( {
105
112
certificatePath : config . https . certPath ,
106
113
certificateContent : config . https . certContent ,
@@ -113,9 +120,11 @@ const buildResolvers = (
113
120
} ,
114
121
115
122
Mutation : {
116
- activateInterceptor : async ( __ : void , args : _ . Dictionary < any > ) => {
117
- const { id, proxyPort, options } = args ;
118
-
123
+ activateInterceptor : async ( __ : void , { id, proxyPort, options } : {
124
+ id : string ,
125
+ proxyPort : number ,
126
+ options : unknown
127
+ } ) => {
119
128
addBreadcrumb ( `Activating ${ id } ` , { category : 'interceptor' , data : { id, options } } ) ;
120
129
121
130
const interceptor = interceptors [ id ] ;
@@ -138,9 +147,11 @@ const buildResolvers = (
138
147
return { success : true , metadata : result } ;
139
148
}
140
149
} ,
141
- deactivateInterceptor : async ( __ : void , args : _ . Dictionary < any > ) => {
142
- const { id, proxyPort, options } = args ;
143
-
150
+ deactivateInterceptor : async ( __ : void , { id, proxyPort, options } : {
151
+ id : string ,
152
+ proxyPort : number ,
153
+ options : unknown
154
+ } ) => {
144
155
const interceptor = interceptors [ id ] ;
145
156
if ( ! interceptor ) throw new Error ( `Unknown interceptor ${ id } ` ) ;
146
157
@@ -160,21 +171,29 @@ const buildResolvers = (
160
171
false
161
172
) ;
162
173
} ,
163
- isActive : ( interceptor : Interceptor , args : _ . Dictionary < any > ) => {
174
+ isActive : ( interceptor : Interceptor , { proxyPort } : { proxyPort : number } ) => {
164
175
try {
165
- return interceptor . isActive ( args . proxyPort ) ;
176
+ return interceptor . isActive ( proxyPort ) ;
166
177
} catch ( e ) {
167
178
reportError ( e ) ;
168
179
return false ;
169
180
}
170
181
} ,
171
- metadata : async ( interceptor : Interceptor ) => {
182
+ metadata : async function ( interceptor : Interceptor , { type } : { type ?: 'DETAILED' | 'SUMMARY' } ) {
172
183
if ( ! interceptor . getMetadata ) return undefined ;
173
184
185
+ const metadataType = type
186
+ ? type . toLowerCase ( ) as 'summary' | 'detailed'
187
+ : 'summary' ;
188
+
189
+ const timeout = metadataType === 'summary'
190
+ ? INTERCEPTOR_TIMEOUT
191
+ : INTERCEPTOR_TIMEOUT * 10 ; // Longer timeout for detailed metadata
192
+
174
193
try {
175
194
return await withFallback (
176
- interceptor . getMetadata ( ) ,
177
- INTERCEPTOR_TIMEOUT ,
195
+ interceptor . getMetadata ( metadataType ) ,
196
+ timeout ,
178
197
undefined
179
198
) ;
180
199
} catch ( e ) {
0 commit comments