-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support fragments in GraphQlTester #964
Comments
Duplicates #923 |
The As mentioned in #923 (comment), we could also expose It makes sense to have equivalent methods on |
In the meantime, since "documentName" handling can be customized, you could support a name like "myDocument::myFragment1::myFragment2". I haven't tested this, but a custom public class ConcatenatingDocumentSource implements DocumentSource {
private final DocumentSource delegate = new ResourceDocumentSource(
List.of(new ClassPathResource("graphql-test/")), List.of(".graphql"));
@Override
public Mono<String> getDocument(String name) {
return name.contains("::") ?
Flux.fromArray(name.split("::")).flatMap(this.delegate::getDocument).reduce((s, s2) -> s + s2) :
this.delegate.getDocument(name);
}
} You plug that in via |
Thanks, this workaround is exactly what I needed to move forward without having to abandon fragment utilization in my test cases. Much appreciated! |
@rstoyanchev Thank you very much! This worked great for me as well! |
I am in the process of converting a codebase from the old GraphQL Java Kickstart library over to
spring-graphql
.The test template in the testing framework for that library included a parameter that allowed you to optionally pass in fragment resource paths.
It would be helpful in the maintenance of test requests to support the loading of GraphQL fragments from disk. Currently, as far as I can tell fragments are only supported in the
document
method, which requires you to juxtapose your fragment with your query in a single string.Being able to write something along the following lines:
would be much nicer than having to repeat boilerplate in your test requests.
The text was updated successfully, but these errors were encountered: