eclipse-sirius / sirius-web

Sirius Web: open-source low-code platform to define custom web applications supporting your specific visual languages
https://eclipse.dev/sirius/sirius-web.html
Eclipse Public License 2.0
72 stars 48 forks source link

Switch to spring-graphql #1630

Open sbegaudeau opened 1 year ago

sbegaudeau commented 1 year ago

For this issue, there are multiple tasks that need to be performed:

After that, add a dependency to

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-graphql</artifactId>
        </dependency>

in the various graphql projects such as:

And change all the data fetchers from this:

@MutationDataFetcher(type = "Mutation", field = MutationCreateProjectDataFetcher.CREATE_PROJECT_FIELD)
public class MutationCreateProjectDataFetcher implements IDataFetcherWithFieldCoordinates<IPayload> {
    @Override
    public IPayload get(DataFetchingEnvironment environment) throws Exception {
        // ...
    }
}

to this:

@Controller
public class MutationCreateProjectDataFetcher {
    @MutationMapping
    public IPayload createProject(@Argument CreateProjectInput input) {
        // ...
    }
}

Once this is done, you will also need to remove the dependency to subscription-transport-ws to use graphql-ws instead on the frontend.

When everything is over and the code compiles, use the following configuration properties in the application{-dev}.properties of Sirius Web:

After that a release will be needed to let consumers of Sirius Components adapt to this sizable API change.

sbegaudeau commented 1 year ago

Have a look at the official Apollo documentation regarding the migration from subscription-transport-ws to graphql-ws here and the spring-graphql documentation there.

sbegaudeau commented 1 year ago

We will also be able to delete sirius-components-graphiql since GraphiQL is provided by spring-graphql with an up to date version.