Skip to content

Instantly share code, notes, and snippets.

@mustafa-qamaruddin
Last active June 17, 2022 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustafa-qamaruddin/a14bd88a1575e8b8b7cc9ceeefdbbc46 to your computer and use it in GitHub Desktop.
Save mustafa-qamaruddin/a14bd88a1575e8b8b7cc9ceeefdbbc46 to your computer and use it in GitHub Desktop.
access account
# create some data
mutation upsert($values:HypiUpsertInputUnion!) {
upsert(values:$values){
id
}
}
{
"values": {
"Pair": {
"hypi": {
"id": "p1"
},
"key": "k",
"value": "v"
}
}
}
# create a user
mutation createAccount($value:AccountInput!) {
createAccount(value:$value)
{
id
instanceId
}
}
{
"value": {
"hypi": {
"id": "user101"
},
"username": "cameron",
"emails": {"value": "cameron@crlog.io"},
"password": {
"value": "1234567890"
}
}
}
# create access right
mutation upsert($values:HypiUpsertInputUnion!) {
upsert(values:$values){
id
instanceId
}
}
{
"values": {
"AccessRight": {
"hypi": {
"id": "rbp.allow-user",
"instanceId": "01FW4Q87QH10DH5N0QDAAZJA0R"
},
"targetInstanceId": "01FW4Q87QH10DH5N0QDAAZJA0R",
"resource": "p1",
"resourceType": "Pair",
"resourceOwnerId": "01FW4Q5V127R1ANNJ1PKYSY5AT",
"resourceOwnerInstanceId": "01FW4Q5V128Q1E5K69MQD62BQG",
"operationType": "Query",
"operation": "get",
"permissionType": "RBP",
"approved": true,
"members": [
{
"hypi": {
"id": "01FW5RZHJRYJCCNQ560627CRK4",
"instanceId": "01FW4Q87QH10DH5N0QDAAZJA0R"
}
}
]
}
}
}
# login the user
{
login(
username: "cameron",
password: "1234567890"
) {
sessionToken
sessionExpires
errorCode
errorMsg
}
}
# access the data
{
get(type: Pair, id: "p1") {
... on Pair {
hypi {
id
instanceId
createdBy
}
key
value
}
}
}
mutation upsert($values:HypiUpsertInputUnion!) {
upsert(values:$values){
id
instanceId
}
}
{
"values": {
"AccessRight": {
"hypi": {
"id": "rbp.allow-user",
"instanceId": "01FW4Q87QH10DH5N0QDAAZJA0R"
},
"targetInstanceId": "01FW4Q87QH10DH5N0QDAAZJA0R",
"resource": "p1",
"resourceType": "Pair",
"resourceOwnerId": "01FW4Q5V127R1ANNJ1PKYSY5AT",
"resourceOwnerInstanceId": "01FW4Q5V128Q1E5K69MQD62BQG",
"operationType": "Query",
"operation": "get",
"permissionType": "RBP",
"approved": true,
"membersSourceType": "MyAwesomeNewType",
"membersSourceField": "myAwesomeNewField"
}
}
}
type MyAwesomeNewType {
# ... other fields
myAwesomeNewField: [Account!]
# ... other fields
}
mutation upsert($values:HypiUpsertInputUnion!) {
upsert(values:$values){
id
instanceId
}
}
{
"values": {
"MyAwesomeNewtype": {
# ... other fields
"members": [
{
"hypi": {
"id": "01FW5RZHJRYJCCNQ560627CRK4",
"instanceId": "01FW4Q87QH10DH5N0QDAAZJA0R"
}
}
]
# ... other fields
}
}
}
mutation link(
$from: HypiMutationType!,
$to: HypiMutationType!,
$via: String!,
$whereFromID: String!,
$andToID: String!
) {
link(
from: $from,
to: $to,
via: $via,
whereFromID: $whereFromID,
andToID: $andToID
)
}
{
"from": "MyAwesomeNewType",
"to": "Account",
"via": "myAwesomeNewField",
"whereFromID": objectIDOfMyAwesomeNewType,
"andToID": memberAccountId
}
mutation upsert($values:HypiUpsertInputUnion!) {
upsert(values:$values){
id
instanceId
}
}
{
"values": {
"AccessRight": {
"hypi": {
"id": "rbp.allow-user-to-query-find-another-user",
"instanceId": "01FW4Q87QH10DH5N0QDAAZJA0R"
},
"targetInstanceId": "01FW4Q87QH10DH5N0QDAAZJA0R",
"resource": "replaceMeWithTargetUserHypiAccountId",
"resourceType": "Account",
"resourceOwnerId": "replaceMeWithTargetUserHypiAccountId",
"resourceOwnerInstanceId": "01FW4Q5V128Q1E5K69MQD62BQG",
"operationType": "Query",
"operation": "find",
"permissionType": "RBP",
"approved": true,
"membersSourceType": "MyAwesomeNewType",
"membersSourceField": "myAwesomeNewField"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment