Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to expose authorization metadata through the graphql schema #1482

Open
Tracked by #1485
dimatill opened this issue Oct 29, 2022 · 0 comments
Open
Tracked by #1485
Milestone

Comments

@dimatill
Copy link
Collaborator

  • Every (or certain) Object types could have a special __auth field of AuthMetadata type
  • AuthMetadata type could have 3 fields: query: AuthMetadataQuery, mutation: AuthMetadataMutation, subscription: AuthMetadataSubscription
  • Each of the three AuthMetadataX types could have corresponding fields (all queries, mutations, subscriptions)
  • Each field of AuthMetadataX could have 1 argument which accepts JSON string
  • Argument could contain information about arguments of corresponding query, mutation, subscription
  • Argument could contain placeholders which could be evaluated later
  • Placeholder could have an access to the parent entity e.g. $$parent.id
  • Validation of the argument could be done in graphql validate phase
  • Alternatively, some kind of 'virtual' variable could be introduced e.g. $parent
  • The result of resolving such fields could be the information on whether authorization is passing or not with the current context and provided args
  • Resolving of such fields could just execute auth rules, but not actual resolvers

Example query:

query post($id: ID!) {
  post(id: $id) {
    id
    title
    content
    author {
      id
     }
    __auth {
      mutation {
        deletePost(args: "{ \"id\": \"$$parent.id\" }")
      }
      query {
        userInfo(args: "{ \"userId\": \"$$parent.author.id\" }")
      }
    }
  }
}
@dimatill dimatill modified the milestones: v8, v8.x Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant