leangen / graphql-spqr-spring-boot-starter

Spring Boot 2 starter powered by GraphQL SPQR
Apache License 2.0
275 stars 68 forks source link

Unable to upgrade to `Spring Boot` version `2.7.x` #119

Closed x80486 closed 1 year ago

x80486 commented 2 years ago

Would it be possible to get a new release some time this year? Currently I'm unable to upgrade to Spring Boot version 2.7.x :grimacing:

MarcinLachowicz commented 2 years ago

I would love to have it too

vmikhnevych commented 2 years ago

The issue I get while upgrading to Boot 2.7 is the following exception: org.springframework.beans.BeanInstantiationException: Failed to instantiate [graphql.schema.GraphQLSchema]: Factory method 'graphQLSchema' threw exception; nested exception is java.lang.NoClassDefFoundError: graphql/execution/batched/Batched

kicktipp commented 2 years ago

It is such a wonderful project, but it is not up-to-date (again). I need to fix it locally to use spring 2.7.

kicktipp commented 2 years ago

You can fix it in your gradle build like this:

plugins {
    id 'org.springframework.boot' version "2.7.3"
    // to use  ext['graphql-java.version'] this plugin is needed:
    id "io.spring.dependency-management" version "1.0.13.RELEASE"
}

// https://github.com/leangen/graphql-spqr-spring-boot-starter/issues/119
ext['graphql-java.version'] = '16.2'
SaschaPeukert commented 1 year ago

@kicktipp Any maven version for this?

SaschaPeukert commented 1 year ago

With Spring-Boot 3.0.0 this problem seems to have become even bigger aka its not compatible anymore because spring changed that spring.factories mechanism

kaqqao commented 1 year ago

With GraphQL SPQR v0.12.0 out the door, I will have a look at the state of this project. But, fair warning, there's a good chance that maintaining it in the current shape in light of the official starter is nonsensical. The easiest way forward may be to build a smaller extension on top of the official starter. But that's currently just a theory. Either way, it will take time to explore the options and see what to do,

kaqqao commented 1 year ago

If any of you would like to help upgrade this to the latest Spring Boot and SPQR versions, please do.

michael-simons commented 1 year ago

I see the following issues

A necessary change is to adapt how the auto configuration is loaded. Spring Boot 2.7 supports the old way (with spring.factories) and the new way (with org.springframework.boot.autoconfigure.AutoConfiguration.imports plus using now @AutoConfiguration, with the latter not allowing to proxy @Bean methods anymore, but you are doing that anyway).

I'll send a PR in a sec addressing these things. Feel free to edit whatever you want, especially my changes unrelated to auto config (I don't have a clue honestly how the SPQR / GraphQL system works, I'm just here with my dear colleague @SaschaPeukert). The remaining changes to auto config are sane and will allow proper usage in at least Boot 2.7 and most likely with Boot 3 (given that the GraphQL version is compatible).

kaqqao commented 1 year ago

Thanks a bunch for this! 😊 It's of great help! There seems to be one place where bean method proxying was unfortunately used, but I'm not sure why... I'll have a look in a second.

michael-simons commented 1 year ago

You made the configurational class bean on its own and you can't auto inject into the overloaded method. I pushed this down, so that the configurer is a bean on its own rights, inject the executor. That should work.