Skip to content

Commit 4590894

Browse files
committed
feat: add graphql to the five rest-only admin methods
adminLogout, adminSession, adminMeta, fgaGetModel and fgaReset were rest-only even though each has a GraphQL op on the server -- the SDK simply carried no query for them. All five now work over both protocols. adminMeta and fgaGetModel keep their REST unwrap: the gateway nests the payload under admin_meta / model while the GraphQL ops return the object directly. That leaves adminSignup, updateEnv and generateJWTKeys as the only graphql-only methods; they are the only admin operations with no proto RPC.
1 parent a6bef89 commit 4590894

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

‎src/admin.ts‎

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,17 +268,25 @@ export class AuthorizerAdmin {
268268
adminLogout = (): Promise<Types.ApiResponse<Types.Response>> =>
269269
this.dispatch<Types.Response>(
270270
'AdminLogout',
271-
['rest'],
272-
null,
271+
['graphql', 'rest'],
272+
{
273+
query: 'mutation _admin_logout { _admin_logout { message } }',
274+
operationName: '_admin_logout',
275+
op: '_admin_logout',
276+
},
273277
{ method: 'POST', path: '/v1/admin/logout' },
274278
);
275279

276280
// adminSession refreshes the admin session cookie. (rest-only in JS.)
277281
adminSession = (): Promise<Types.ApiResponse<Types.Response>> =>
278282
this.dispatch<Types.Response>(
279283
'AdminSession',
280-
['rest'],
281-
null,
284+
['graphql', 'rest'],
285+
{
286+
query: 'query _admin_session { _admin_session { message } }',
287+
operationName: '_admin_session',
288+
op: '_admin_session',
289+
},
282290
{ method: 'GET', path: '/v1/admin/session' },
283291
);
284292

@@ -287,8 +295,14 @@ export class AuthorizerAdmin {
287295
adminMeta = (): Promise<Types.ApiResponse<Types.AdminMeta>> =>
288296
this.dispatch<Types.AdminMeta>(
289297
'AdminMeta',
290-
['rest'],
291-
null,
298+
['graphql', 'rest'],
299+
{
300+
query:
301+
'query _admin_meta { _admin_meta { roles default_roles protected_roles is_multi_factor_auth_service_enabled } }',
302+
operationName: '_admin_meta',
303+
op: '_admin_meta',
304+
},
305+
// GraphQL returns AdminMeta directly; REST nests it under admin_meta.
292306
{ method: 'GET', path: '/v1/admin/meta', unwrap: 'admin_meta' },
293307
);
294308

@@ -667,8 +681,12 @@ export class AuthorizerAdmin {
667681
fgaGetModel = (): Promise<Types.ApiResponse<Types.FgaModel>> =>
668682
this.dispatch<Types.FgaModel>(
669683
'FgaGetModel',
670-
['rest'],
671-
null,
684+
['graphql', 'rest'],
685+
{
686+
query: 'query _fga_get_model { _fga_get_model { id dsl } }',
687+
operationName: '_fga_get_model',
688+
op: '_fga_get_model',
689+
},
672690
{ method: 'GET', path: '/v1/admin/fga/model', unwrap: 'model' },
673691
);
674692

@@ -790,8 +808,12 @@ export class AuthorizerAdmin {
790808
fgaReset = (): Promise<Types.ApiResponse<Types.Response>> =>
791809
this.dispatch<Types.Response>(
792810
'FgaReset',
793-
['rest'],
794-
null,
811+
['graphql', 'rest'],
812+
{
813+
query: 'mutation _fga_reset { _fga_reset { message } }',
814+
operationName: '_fga_reset',
815+
op: '_fga_reset',
816+
},
795817
{ method: 'POST', path: '/v1/admin/fga/reset' },
796818
);
797819

0 commit comments

Comments
 (0)