https://github.com/aooppo/graphql
graphql tool for java spring framework
https://github.com/aooppo/graphql
graphql graphql-ui java spring-framework-graphql tool
Last synced: about 1 month ago
JSON representation
graphql tool for java spring framework
- Host: GitHub
- URL: https://github.com/aooppo/graphql
- Owner: aooppo
- Created: 2020-04-29T04:34:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T22:46:57.000Z (about 3 years ago)
- Last Synced: 2025-10-04T01:08:52.892Z (9 months ago)
- Topics: graphql, graphql-ui, java, spring-framework-graphql, tool
- Language: Java
- Homepage: https://github.com/aooppo/graphql
- Size: 1 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README

# Install
- add dependencies into pom.xml
``` xml
cc.voox
graphql
0.9.3
```
- add config into java bean
```java
import cc.voox.graphql.GraphqlProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@ComponentScan(value = {"cc.voox.graphql"})
public class GraphQLConfig {
@Bean()
public GraphqlProperties graphqlProperties() {
GraphqlProperties graphqlProperties = new GraphqlProperties();
graphqlProperties.setScanPath("com.xxx");
return graphqlProperties;
}
}
```
# Usage
- define schema in classpath or custom schema path value (default value: schema.graphql)
```graphql
type Query {
test: String
}
type Book {
id: ID
name: String
pageCount: Int
}
```
#### define resolvers
- use @Query in entity class or method
- use @QueryMethod in method
- use @QueryField in parameter of method
```java
@Query
@Component
public class TestService {
@QueryMethod("bookById")
Map getBookById(@QueryField("id") String id) {
return books
.stream()
.filter(book -> book.get("id").equals(id))
.findFirst()
.orElse(null);
}
}
```
### define scalars
```java
class Currency implements IScalar {
}
```
### define directive
```java
class Lower implements IDirective {
}
```
### define dataloader
```java
class BookDatalodaer implements IDataloader {
}
```