I have a graphql API written using graphql-java-tools and graphql-java. I want to mock a query operation. How can I do this? Is Apollo graphql-tools the only way to achieve this. I havent used any other apolo library in my project yet and didnt want to go that route for just mocking service.
There is no library that supports mocking in java as of now( Apollo-graphql-tools supports only nodejs). I think best way is to mock it yourself creating new objects.
Related
I have a springboot microservice project and I am using graphql. For REST api end points I am aware that we can document using swagger etc.. Graphiql also provides dynamic documentation but is there any other way to create API documentation for the customers who are not so aware of how graphql or Graphiql works.
aaah that might help: You can get (and print) the generated schema programatically:
How to get the generated scheme file .graphqls using SPQR?
so i have a spring boot application and my data source is MySQL via JPA. I am trying to introduce Odata queries to my API's and then fetch data based on those odata params. I was wondering if there are any utils or external libraries i can use to parse the odata query then construct the JPA Specification. I have looked into olingo but im not sure if it is exactly what i am looking for. I was thinking of parsing the query text, and constructing the jpa specifications manually(maybe use reflection is necessary), but if anyone has any tips or advice on how to better approach this it would be much appreciated!!
I was thinking of doing something similar to this but with odata instead. Only issue i see is making this dynamic enough to handle every complex odata query coming in.
https://www.baeldung.com/rest-api-search-language-spring-data-specifications
I'm using spring boot and spqr graphql library. I need to upload a file(s) via graphql. I don't know what object type to expect in the service and I'm assuming that this isn't even supported.
Has anyone tried this? Any advice?
Thanks.
(Assuming you're using SPQR Spring Starter)
Uploading/downloading binaries is currently inconvenient in SPQR, but not impossible. You'd need to override the provided controller with your own and decide how you want to receive the queries and binaries, and how you want to send the results and binaries back. To override the controller, just provide your own bean of GraphQLController type.
Your best bet is implementing the GraphQL multipart request spec which thanks to Spring shouldn't be too complicated.
Btw you can always get to the raw request by injecting #GraphQLRootContext DefaultGlobalContext<NativeWebRequest> request as a method argument. From there you can obtain input and output streams.
You can also wire in a custom ArgumentInjector that can inject something more precise if you want.
In the near future, the starter will support the GraphQL multipart request spec out of the box.
If you're not using the starter, the situation is similar in that you're kind of on your own with implementing the transport for binaries and queries.
But, with all that said, it is generally a best practice to handle dealing with binaries outside of GraphQL completely (only send download URLs and such using GraphQL), so I highly recommend that approach if possible. The reason is that requiring optional specs breaks out-of-the-box compatibility with most clients.
Searched over the net but unable to find the satisfying approach.
I am new to spring boot and aware of starter dependancies,
I want to develop a springboot app using elastic search as a storage system.
Wherever i searched i found that somewhere my service class will have to implement some interface from springframework for ES crud operations.
Is there any other way without implementing or extending the components.
I myself want to create transport client and want to query ES by my code or methods not by overidden ones.
Please if you ahve ever seen any projects you can redirect me to that link .
Thanks.
Assuming I understand you correctly, you can use the Elasticsearch REST client: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low.html
You supply the JSON entities for the queries and parse the responses yourself. Its pretty basic in what it does, so you're not dependent on a lot of third party stuff to perform operations.
I read about the server extensions available in neo4j in server mode. I was wondering if it is possible to somehow annotate repository method to use this extension insted of allowing to create query based on method name or #Query annotation?
If not, is there easy way to invoke REST interface methods using Neo4jTemplate?
That's not possible right now, it would be cool though, feel free to raise a JIRA issue that describes your suggestion in more detail. Perhaps Spring-Data-REST Clients allow such a thing.