micronaut-graphql icon indicating copy to clipboard operation
micronaut-graphql copied to clipboard

Support @Refreshable

Open johndevs opened this issue 2 years ago • 1 comments

Feature description

I am generating the the GraphQL schema at runtime and I'd wish to update the schema when an external modification is made.

Preferably I'd like to use the @Refreshable annotation as that is what is used elsewhere and can easily be triggered via a REST end-point.

e.g

@Bean
@Refreshable
public GraphQL graphQL() {
...

}

Unfortunately this is not possible currently due to GraphQL missing a default constructor.

johndevs avatar Dec 16 '23 17:12 johndevs

As a work-around I was able to achieve it by using

@Bean
@Replaces(GraphQLInvocation.class)
@Refreshable
public GraphQLInvocation graphQLInvocation(GraphQL graphQL,
                                           GraphQLExecutionInputCustomizer graphQLExecutionInputCustomizer,
                                           @Nullable BeanProvider<DataLoaderRegistry> dataLoaderRegistry) {
        return new DefaultGraphQLInvocation(graphQL, graphQLExecutionInputCustomizer, dataLoaderRegistry);
}

johndevs avatar Dec 17 '23 07:12 johndevs