amplify-category-api
amplify-category-api copied to clipboard
Global Auth (inheritance) for @sql data
Describe the feature you'd like to request
I do not see a solution to configure global auth rules for an SQL-backed data type. Please correct me if I'm missing something, but this makes it a bit tedious and repetitive to assign an auth rule to the query and then to each field the type can return. I'd love to see my query auth rules inherited by the fields until an override is in place.
Describe the solution you'd like
Example schema is below:
type Contact {
id: Int
first_name: String
last_name: String
}
type Query {
listContacts(companyId: Int): [Contact]
@sql(reference: "getContacts")
@auth(rules: [
{ allow: private, provider: userPools },
{ allow: public, provider: apiKey }
])
}
I'd like to see a valid response when authenticated to my userpool. Currently, it's only working if I add field-level auth to each field in the Contact type which seems needless. If all the fields could inherit the auth rule above until then your field level can be treated like overrides which is more similar to a DynamoDB backed data source.
Describe alternatives you've considered
The @function directive has been my alternative, but it's far easier to let this construct generate the lambdas to run the query.
Additional context
No response
Is this something that you'd be interested in working on?
- [ ] 👋 I may be able to implement this feature request
Would this feature include a breaking change?
- [ ] ⚠️ This feature might incur a breaking change