I tried the mutation with RS256
and it’s working for me.
Schema:
type User {
username: String! @id
org: [Org]
}
interface Org {
id: ID!
name: String! @search(by: [hash])
users: [User!]! @hasInverse(field: org)
createdOn: DateTime!
updatedOn: DateTime!
}
interface Location {
street: String! @search(by: [fulltext])
city: String! @search(by: [fulltext])
county: String! @search(by: [exact])
state: String! @search(by: [exact])
country: String! @search(by: [exact])
zip: Int! @search
}
type OwnerOrg implements Org & Location @auth(
add: { and: [
{ rule: "{ $isAuthenticated: { eq: \"true\" } }" },
{ rule: "{ $role: { eq: \"USER_ADMIN\" } }"},
]},
query: { and: [
{ rule: "{ $isAuthenticated: { eq: \"true\" } }" },
{ or: [
{ rule: "{ $role: { eq: \"USER_ADMIN\" } }"},
{ rule: "{ $role: { eq: \"USER_INTERNAL\" } }"},
]},
{ rule: """query($orgID: ID!) {
queryOwnerOrg( filter: { id: [$orgID] } ) {
id
}
}"""},
]},
update: { and: [
{ rule: "{ $isAuthenticated: { eq: \"true\" } }" },
{ rule: "{ $role: { eq: \"USER_ADMIN\" } }"},
{ rule: """query($orgID: ID!) {
queryOwnerOrg( filter: { id: [$orgID] } ) {
id
}
}"""},
]},
delete: { and: [
{ rule: "{ $isAuthenticated: { eq: \"true\" } }" },
{ rule: "{ $role: { eq: \"USER_ADMIN\" } }"},
{ rule: """query($orgID: ID!) {
queryOwnerOrg( filter: { id: [$orgID] } ) {
id
}
}"""},
]},
) {
ownerName: String @search(by: [exact, term, fulltext, regexp])
}
Mutation:
mutation AddOwnerOrgs($input: [AddOwnerOrgInput!]!) {
addOwnerOrg(input: $input) {
numUids
ownerOrg {
id
name
__typename
}
}
}
Variable:
{
"input" : [{
"name" : "Arijit",
"street" : "random",
"city" : "random",
"county": "random",
"state": "random",
"country": "random",
"zip": 11111,
"createdOn": "2020-01-01",
"updatedOn": "2019-01-01",
"users" : [ {"username" : "arijit"}]
}]
}
JWT payload:
{
"sub": "1234567890",
"name": "John Doe",
"admin": true,
"iat": 1626239022,
"https://xyz.io/jwt/claims": {
"isAuthenticated": "true",
"role": "USER_ADMIN",
"orgID": "42"
},
"nickname": "john.forstmeier"
}
Result:
{
"data": {
"addOwnerOrg": {
"numUids": 1,
"ownerOrg": [
{
"id": "0x60",
"name": "Arijit",
"__typename": "OwnerOrg"
}
]
}
}
}