graphql-spqr | Build a GraphQL service in seconds | GraphQL library
kandi X-RAY | graphql-spqr Summary
kandi X-RAY | graphql-spqr Summary
GraphQL SPQR (GraphQL Schema Publisher & Query Resolver, pronounced like speaker) is a simple-to-use library for rapid development of GraphQL APIs in Java.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generate a GraphQL Schema
- Initializes the factory
- Provides default modules
- Build a GraphQLObjectType from the given java type
- Gets all child queries associated with a given domain
- Gets the interfaces
- Returns the operation arguments
- Returns the named argument name
- Returns the default value
- Gets the scalar mapping
- Gets the input fields
- Generate a GraphQLInputObjectType
- Build the client directive
- Sets up the schema generator
- Creates a type adapter for the given type
- Compares two annotated types
- Scan the given type
- Obtains a GraphQLObjectType from the given JavaType
- Computes the number of complexities for the given field
- Returns the type discriminator field
- Returns the value of the named argument
- Parse a value
- Converts a Java type to a GraphQL type
- Parse a JSON value
- Determine the type of the result
- Generates a GraphQLInterfaceType
graphql-spqr Key Features
graphql-spqr Examples and Code Snippets
Community Discussions
Trending Discussions on graphql-spqr
QUESTION
I'm new to Spring Boot and I just started using graphql-spqr for Spring Boot since it allows for easy bootstrapping of Java projects.
However, as per my understanding, GraphQL basically allows the fetching of selected fields from the database. As per the examples, I've seen, this type of selection in the graphql-spqr library happens on the client side. Is there a way to do selection both client-side and server-side so as to speed up the queries?
I've looked into EntityGraph exmaples for GraphQL but they are mostly implemented for complex quieres that involve JOINs. However, nothing exists for simple queries like findAll(), findById() etc.
I would like to use findAll() with the server fetching only the fields as requested by the client. How can I do that?
...ANSWER
Answered 2021-Apr-19 at 08:49What was said in the comments is correct: GraphQL (and hence SPQR, as it's merely a tool to hook the schema up) does not know anything about SQL, databases, JOINs or anything else. It's a communication protocol, the rest is up to you. As for your situation, you'd have to inject the subselection into the resolver and pass it down to SQL. In the simplest case, it can look like this (in pseudo code):
QUESTION
I am using graphql-spqr-spring-boot-starter, version 0.0.5 in my spring boot application.
@GraphQLApi & @GraphQLQuery working fine and I am fetching data on /gui as well.
But as many have faced I am trying to apply the authentication part on graphql server calls. I am using JWT token in my application for REST API authorization/authentication.
So I have token which I suppose can be used for validation here as well.
I have tried using:
...ANSWER
Answered 2021-Apr-17 at 11:07EDIT: GraphQL SPQR Spring Boot starter v0.0.6 fixed the issue and should work out of the box.
This is a bug in the starter. It doesn't properly detect the types when JDK proxies (and not CGLib) are used. I will make sure to fix this for the next release. There's a couple of ways to temporarily work around this, but none of them are nice unfortunately.
You could e.g. force Spring to use CGLIB by e.g.
QUESTION
I have a basic Java entity class.
...ANSWER
Answered 2021-Mar-05 at 10:23Oh, that was actually quite simple. Just needed to dig up the right example from the graphql-spqr-examples.
QUESTION
I'm using https://github.com/leangen/graphql-spqr with spring-boot java application. I can reach to alias name easily but how can I reach to original fieldName?
...ANSWER
Answered 2021-Feb-26 at 15:44Posting my original answer here as well.
You want the underlying field names, but from a level above. Still possible, but ugly :(
QUESTION
Working with graphql-spqr and Spring Boot, I'm trying to run the project but I run into this:
...ANSWER
Answered 2020-Nov-27 at 15:30Removing the protobuf Timestamp fields fix the problem!
After changing my return Object it worked out, I had to refactor com.google.protobuf.Timestamp
to Date, LocalDate or even String and it works perfectly.
QUESTION
We are using graphql-spqr and graphql-spqr-spring-boot-starter for a new project (With Spring DataJPA, hibernate and so on).
We have a mutation like this:
...ANSWER
Answered 2020-Mar-30 at 12:16I can come with a couple of things you may want to consider.
1) Eagerly load as needed
You can always preemptively check what fields the query wants and eagerly load them. The details are well explained in the Building efficient data fetchers by looking ahead article at graphql-java blog.
In short, you can get call DataFetchingEnvironment#getSelectionSet()
which will give you DataFetchingFieldSelectionSet
and that contains all the info you need to optimize loading.
In SPQR, you can always get a hold of DataFetchingEnvironment
(and a lot more) by injecting ResolutionEnvironment
:
QUESTION
I want to create mutation apis where input can be of different types, something like interface which we have in types. I know that we cannot have interface in input types, I want to know how we can support multiple input types in just one input. To explain the problem, I am using a dummy example:
...ANSWER
Answered 2020-Feb-03 at 04:19Input union type can solve your problem but unfortunately it is not supported now . However , the good news is that there is already a RFC for this feature which means it is possible it will include in the next GraphQL specification release.
At this moment , I will model it using the nested input with an enum to differentiate which animal type the user is actually want to create. Somethings look like :
QUESTION
I use io.leangen.graphql.spqr
library version 0.9.6
and I need to exclude mutations from Query
root node into the Doc.
My GraphQLController.kt
looks this way:
ANSWER
Answered 2020-Jan-31 at 09:29It's bug. You're using a very old version of SPQR (Feb. 2018). This has been fixed a long long time ago. Please try to follow the releases as much as possible, as lots of things are getting fixed and improved.
It is possible to work around the bug by customizing the ResolverBuilder
s, but I wouldn't recommend going that route.
The Spring Starter (if even relevant to you) is currently lagging behind (not yet on the latest SPQR version) but I'm actively working on the new release. Should be out very soon.
Btw, your setup has a lot of redundancy. Can be simplified to:
QUESTION
I noticed that GraphQL-SPQR has at least a couple properties that you can configure (e.g. graphql.spqr.gui.enabled=true
). Is there a configuration for specifying to use Gson instead of Jackson for object serialization/deserialization?
If there is not configuration, is there some other way I can use Gson instead of Jackson for GraphQL-SPQR?
NOTE: I am already using
spring.http.converters.preferred-json-mapper=gson
in myapplication.properties
, to override spring in general to use Gson instead of Jackson, but it doesn't seem to override GraphQL-SPQR's value mapper (defaults to Jackson).
Any help is greatly appreciated :)
...ANSWER
Answered 2020-Jan-05 at 23:34All you need to do is register a ValueMapperFactory
bean, e.g.
QUESTION
I'm building web application that is using GraphQL with leangen graphql-spqr.
I have problem with exception handling. For example inside service class I'm using spring bean validation that checks for some validity and if its not correct, its throwing ConstraintViolationException.
Is there any way to add some exception handler that would send proper message to the client? Something like ExceptionHandler for controllers in rest api?
Or maybe it should be done in other way?
ANSWER
Answered 2019-Sep-09 at 10:39Solution I have found is to implement DataFetcherExceptionHandler, override onException method and set it as default exception handler.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install graphql-spqr
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page