Skip to content

Commit

Permalink
feat(backend): backend tenant graphql resolvers (#3234)
Browse files Browse the repository at this point in the history
* feat: backend tenant graphql resolvers

* chore: formatting

* fix: extra testing db for tenants

* feat: bruno collection

* feat: update graphql schema comments

* fix: review comments

* feat: optional idp secret & consent url

* feat: tenant response requirement

* feat: make delete operator-only

* chore: cleanup
  • Loading branch information
njlie authored Feb 3, 2025
1 parent 83c844d commit 31df89e
Show file tree
Hide file tree
Showing 22 changed files with 2,679 additions and 91 deletions.
50 changes: 50 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Create Tenant.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
meta {
name: Create Tenant
type: graphql
seq: 54
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
mutation CreateTenant($input: CreateTenantInput!) {
createTenant(input:$input) {
tenant {
id
email
apiSecret
idpConsentUrl
idpSecret
}
}
}
}

body:graphql:vars {
{
"input": {
"email": "example@example.com",
"apiSecret": "test-secret",
"idpConsentUrl": "https://example.com/consent",
"idpSecret": "test-idp-secret"
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}

script:post-response {
const body = res.getBody();

if (body?.data) {
bru.setEnvVar("tenantId", body.data.createTenant.tenant?.id);
}
}
31 changes: 31 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Delete Tenant.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
meta {
name: Delete Tenant
type: graphql
seq: 56
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
mutation DeleteTenant($id: String!) {
deleteTenant(id:$id) {
success
}
}
}

body:graphql:vars {
{
"id": "{{tenantId}}"
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
43 changes: 43 additions & 0 deletions bruno/collections/Rafiki/Rafiki Admin APIs/Update Tenant.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
meta {
name: Update Tenant
type: graphql
seq: 55
}

post {
url: {{RafikiGraphqlHost}}/graphql
body: graphql
auth: none
}

body:graphql {
mutation UpdateTenant($input: UpdateTenantInput!) {
updateTenant(input:$input) {
tenant {
id
email
apiSecret
idpConsentUrl
idpSecret
}
}
}
}

body:graphql:vars {
{
"input": {
"id": "{{tenantId}}",
"email": "updated@example.com",
"apiSecret": "updated-test-secret",
"idpConsentUrl": "https://example.com/consent-updated",
"idpSecret": "updated-test-idp-secret"
}
}
}

script:pre-request {
const scripts = require('./scripts');

scripts.addApiSignatureHeader();
}
1 change: 1 addition & 0 deletions bruno/collections/Rafiki/environments/Local Playground.bru
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ vars {
assetIdTigerBeetle: 1
assetCode: USD
assetScale: 2
senderTenantId: 438fa74a-fa7d-4317-9ced-dde32ece1787
}
1 change: 1 addition & 0 deletions bruno/collections/Rafiki/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const scripts = {
signature = this.generateBackendApiSignature(formattedBody)
}
req.setHeader('signature', signature)
req.setHeader('tenant-id', bru.getEnvVar('senderTenantId'))
},

addHostHeader: function (hostVarName) {
Expand Down
Loading

0 comments on commit 31df89e

Please sign in to comment.