Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Data Fetcher in gorm-graphql 2.0.0 + MultiTenancy project - Fails Startup #49

Open
ianibo opened this issue Apr 17, 2020 · 0 comments

Comments

@ianibo
Copy link

ianibo commented Apr 17, 2020

heya - 2.0.0 looks really good and MultiTenancy support is definitely better - out of the box confirmed working with Database-Per-Tenant mappings too - so that's great.

Trying to add in a custom data fetcher when working in Multi-Tenancy mode seems to encounter a similar problem to v1 with static access at applicaiton startup:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQL': Cannot resolve reference to bean 'graphQLSchema' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphQLSchema': Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'generate' threw exception; nested exception is org.grails.datastore.mapping.multitenancy.exceptions.TenantNotFoundException: Tenant could not be resolved outside a web request

The project works perfectly with the out-of-the-box config until we declare a custom fetcher (Simplified example):

static graphql = GraphQLMapping.lazy {
  query('generalAlertBaseQuery', pagedResult(AlertBase)) {
    defaultListArguments()
    argument('qterm', String) {
      nullable true
      description "Left anchored alert name to search for"
    }
    dataFetcher(new PaginatedEntityDataFetcher<List<AlertBase>>(AlertBase.gormPersistentEntity)     {
      @Override
      protected DetachedCriteria buildCriteria(DataFetchingEnvironment environment) {
        def q = new DetachedCriteria(AlertBase).build {
          rlike('name',/${environment.getArgument('qterm')}/)
        }
        return q
      }
    })
  }
}

This code is yanked directly from a v1 test rig, and I've only scanned over the updated 2.0.0 docs so apologies if I've missed something critical.

Is it possible that custom fetchers can be made to work in the multi-tenant setup? WIll try and update the test project to recreate this in a simple env.

@ianibo ianibo changed the title Custom Data Fetcher + MultiTenancy v2.0.0 - Custom Data Fetcher in MultiTenancy project Apr 17, 2020
@ianibo ianibo changed the title v2.0.0 - Custom Data Fetcher in MultiTenancy project Custom Data Fetcher in gorm-graphql 2.0.0 + MultiTenancy project Apr 17, 2020
@ianibo ianibo changed the title Custom Data Fetcher in gorm-graphql 2.0.0 + MultiTenancy project Custom Data Fetcher in gorm-graphql 2.0.0 + MultiTenancy project - Fails Startup Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant