mirror of
https://github.com/graphql-hive/console
synced 2026-04-27 09:27:17 +00:00
55 lines
1.2 KiB
TypeScript
55 lines
1.2 KiB
TypeScript
import { graphql } from '../../../testkit/gql';
|
|
import { execute } from '../../../testkit/graphql';
|
|
|
|
const WhoAmI = graphql(`
|
|
query projectBySlug {
|
|
whoAmI {
|
|
resolvedPermissions {
|
|
level
|
|
resolvedPermissionGroups {
|
|
permissions {
|
|
permission {
|
|
id
|
|
}
|
|
}
|
|
}
|
|
resolvedResourceIds
|
|
}
|
|
}
|
|
}
|
|
`);
|
|
|
|
/**
|
|
* Get a object representation of all the permissions issued to an access token.
|
|
*/
|
|
export function fetchPermissions(accessToken: string) {
|
|
return execute({
|
|
document: WhoAmI,
|
|
authToken: accessToken,
|
|
})
|
|
.then(e => e.expectNoGraphQLErrors())
|
|
.then(res => res.whoAmI?.resolvedPermissions);
|
|
}
|
|
|
|
const DeleteAccessTokenMutation = graphql(`
|
|
mutation DeleteAccessTokenMutation($accessTokenId: ID!) {
|
|
deleteAccessToken(input: { accessToken: { byId: $accessTokenId } }) {
|
|
error {
|
|
message
|
|
}
|
|
ok {
|
|
deletedAccessTokenId
|
|
}
|
|
}
|
|
}
|
|
`);
|
|
|
|
export function deleteAccessToken(accessTokenId: string, authToken: string) {
|
|
return execute({
|
|
document: DeleteAccessTokenMutation,
|
|
variables: {
|
|
accessTokenId,
|
|
},
|
|
authToken,
|
|
});
|
|
}
|