From c68732bc23e8b0988cb77d8ddd25afcfe3f0edba Mon Sep 17 00:00:00 2001 From: Sooraj Date: Wed, 24 Jan 2024 11:50:13 +0530 Subject: [PATCH] [RFC/v3] Presets in Permissions Idea is to add presets in the permission so that the Types and Commands can have type or argument presets. --- rfcs/Presets in Permissions.md | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 rfcs/Presets in Permissions.md diff --git a/rfcs/Presets in Permissions.md b/rfcs/Presets in Permissions.md new file mode 100644 index 0000000000000..e3907a9e97421 --- /dev/null +++ b/rfcs/Presets in Permissions.md @@ -0,0 +1,40 @@ +# Presets in Permissions + +As a part of command permissions, we want to be able to control what values for an argument a particular role can pass. + +The following changes are proposed to the metadata. + +For command permissions, allow specifying a set of argument values which will be preset. Arguments which have been preset no longer get generated in the GraphQL schema. + +```yaml +kind: CommandPermissions +version: v1 +definition: +  commandName: delete_user +  permissions: +    - role: user +      allowExecution: true +      argumentPresets: +        - argument: user_id +          value: +            sessionVariable: x-hasura-user-id +``` + +A similar change would be required for model arguments / ModelPermissions. + +Also, for supporting complex input objects, we will allow input presets in TypePermissions as well + +```yaml +kind: TypePermissions +version: v1 +definition: +  typeName: DeleteUserInput +  permissions: +    - role: user +      input: +        fieldPresets: +          - field: is_frozen +            value: +              literal: false +``` +Any field which has been preset will not be generated in the GraphQL schema. If all fields of a type have been preset then the parent field / argument will not be generated.