Federation-graphql-java-support for GraphQL-SPQR

Hi,

We use code first approach using GraphQL-SPQR in Spring. With SPQR, schema is generated during query time.
When I tried to integrate federation-jvm, I got this error.

Caused by: org.springframework.graphql.execution.MissingSchemaException: No GraphQL schema definition was configured.
at java.base/java.util.Optional.orElseThrow(Optional.java:403) ~[na:na]
at org.springframework.graphql.execution.DefaultSchemaResourceGraphQlSourceBuilder.initGraphQlSchema(DefaultSchemaResourceGraphQlSourceBuilder.java:141)

Any plans to support this?

Hello :wave:
Without having some github repository that reproduces the error it is hard to guess what might be the underlying issue. I’m not familiar with graphql-spqr so unsure how well it integrates with the federation. It definitely should be possible but I don’t know how easy/hard it is.

In general we ask library maintainers to provide a sample integration that can be used to run our compatibility tests and the results are published on our website → Federation-compatible subgraph implementations.

Thanks,
Derek

Thanks Derek. I was able to figure out.

I had to do like below in my spring application to change the generated schema using Federation transform.

	@Bean
	public ExecutableSchema graphQLExecutableSchema(GraphQLSchemaGenerator schemaGenerator) {
		ExecutableSchema schema = schemaGenerator.generateExecutable();
		GraphQLSchema fedSchema = Federation.transform(schema.getSchema()).build();
		String printedSchema = new SchemaPrinter(
				// Tweak the options accordingly
				SchemaPrinter.Options.defaultOptions().
						includeDirectives(true)
		).print(fedSchema);
		System.out.println(printedSchema);

		return new ExecutableSchema(fedSchema, schema.getTypeRegistry(), schema.getBatchLoaders(), null);
	}```