apache / apache/grails-core

Multi-Tenant domain error: Filter [tenantId] parameter [tenantId] value not set"

Open
#14,338 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-data-graphql
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Environment:
- Grails 6.2.0 (JDK-17), Grails 5.3.3 (JDK-11)
- gorm-graphql-plugin 3.0.0

I have refered your example in [https://github.com/grails/gorm-graphql/blob/4.0.x/examples/grails-tenant-app/grails-app/domain/grails/tenant/app/User.groovy](https://github.com/grails/gorm-graphql/blob/4.0.x/examples/grails-tenant-app/grails-app/domain/grails/tenant/app/User.groovy)

My Grails app is a multi-tenant system. The relevant files are as below
application.yml (only key portion):
```

grails:
profile: vue
codegen:
defaultPackage: worker.order
gorm:
failOnError: true
reactor:
events: false
multiTenancy:
mode: DISCRIMINATOR # SCHEMA, DATABASE, DISCRIMINATOR
tenantResolverClass: com.workerorder.multitenancy.CurrentUserByJwtTenantResolver
```

domain TenantFunc:
```

class TenantFunc implements MultiTenant {
String vueComponentName
String funcname
int displayorder = 0
String position
boolean active
String updatedBy
String createdBy
Date dateCreated
Date lastUpdated

String tenantName
static graphql = true
static mapping = {
tenantId name: 'tenantName'
active default:'true'
}

static constraints = {
tenantName maxSize: FieldLen.TENANT_NAME, index:'tenant_all_func_tenant_func'
vueComponentName maxSize: 60, unique: ['tenantName']
funcname maxSize: 100, unique: ['tenantName']
position maxSize: 20
}

static graphql = true
}
```

graphql in http://localhost:8080/graphql/browser :

```
query {
tenantFuncList {
id

}
}
```

result:
```

{
"data": {
"tenantFuncList": null
},
"errors": [
{
"message": "Exception while fetching data (/tenantFuncList) : Filter [tenantId] parameter [tenantId] value not set",
"errorType": "DataFetchingException",
"locations": [
{
"line": 2,
"column": 3
}
]
}
]
}
```

How to solve this error ? Thanks

Contributor guide

Open the contributing guide

Research direction

Start by comparing the application.yml multi-tenancy settings and TenantFunc domain mapping with the linked grails-tenant-app User.groovy example, then reproduce the tenantFuncList query in the GraphQL browser. Done means the query returns the tenant-scoped list without the tenantId parameter error; no test file is mentioned in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, groovy
Domain
api, backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.