Skip to content

Missing Dataloaders in AOT/GraalVM Native #2237

@MrOstling

Description

@MrOstling

When we updated to 10.4.0 we were unable to get dataloaders for apps that use AOT or GraalVM.

We tracked down the issue to the new dataloader reload feature changing a class to an interface.

Before 10.4.0:

AOT generated
public static BeanDefinition getDgsDataLoaderProviderBeanDefinition() {
RootBeanDefinition beanDefinition = new RootBeanDefinition(DgsDataLoaderProvider.class);
beanDefinition.setInitMethodNames("findDataLoaders$graphql_dgs");
beanDefinition.setFactoryBeanName("com.netflix.graphql.dgs.springgraphql.autoconfig.DgsSpringGraphQLAutoConfiguration");
beanDefinition.setInstanceSupplier(getDgsDataLoaderProviderInstanceSupplier());
return beanDefinition;
}

After 10.4.0:

AOT generated
public static BeanDefinition getDgsDataLoaderProviderBeanDefinition() {
RootBeanDefinition beanDefinition = new RootBeanDefinition(DgsDataLoaderProvider.class);
beanDefinition.setFactoryBeanName("com.netflix.graphql.dgs.springgraphql.autoconfig.DgsSpringGraphQLAutoConfiguration");
beanDefinition.setInstanceSupplier(getDgsDataLoaderProviderInstanceSupplier());
return beanDefinition;
}

The missing init method causes the dataloader registry not to get populated.

Proposed fix:
Change DgsDataLoaderProvider to DefaultDgsDataLoaderProvider when creating the bean here. This allows AOT to detect the @PostConstruct annotation properly in DefaultDgsDataLoaderProvider. This is analogous to the changes made in this PR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions