Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

feat: added ability to use strings for GraphQl queries when using GraphQLTestTemplate #807

Conversation

bsara
Copy link

@bsara bsara commented Apr 19, 2022

Currently, when using GraphQLTestTemplate, one can only submit queries that are in resource files. There are many clients, however, that may want to submit queries via a string that is inlined with their tests:

gqlTestTemplate.post(
  "query blah {"
  + "  myField"
  + "}"
);

For these cases, I've added a series of overloaded postForString methods to GraphQLTestTemplate which allow the passing of a string value for a query instead of always requiring a Resource be used.

Simple usage is as follows:

// Java
gqlTestTemplate.postForString(
  "query blah {"
  + "  myField"
  + "}"
);
// Kotlin
gqlTestTemplate.postForString("""
  query blah {
    myField
  }
""")

@bsara bsara changed the title Added ability to use strings for GraphQl queries when using GraphQLTestTemplate feat: added ability to use strings for GraphQl queries when using GraphQLTestTemplate Apr 20, 2022
@m1ngyuan
Copy link

m1ngyuan commented Apr 30, 2022

You can use
Mono<GraphQLResponse> post(GraphQLRequest request);
Maybe it can better what you need

@bsara
Copy link
Author

bsara commented May 9, 2022

@m1ngyuan, that does not solve the same problem here. I'm looking to just pass a string as the query, not a GraphQLRequest object or a file resource. I don't really care about getting a reactive response back.

@oliemansm oliemansm added this to the 13.0.0 milestone Jul 21, 2022
@oliemansm oliemansm merged commit 5b7ca34 into graphql-java-kickstart:master Jul 21, 2022
@oliemansm
Copy link
Member

Thanks @bsara

@bsara
Copy link
Author

bsara commented Aug 8, 2022

Thanks for the merge @oliemansm

@bsara bsara deleted the add-ability-to-pass-strings-to-graphqltesttemplate branch November 15, 2023 18:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants