grails / gorm-graphql

An automatic GraphQL schema generator for GORM
Apache License 2.0
80 stars 23 forks source link

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

Open wureka opened 2 months ago

wureka commented 2 months ago

Environment:

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

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<TenantFunc> {
    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