Comments (2)
https://github.com/graphql-java-kickstart/graphql-java-servlet
from graphql-calculator.
下边示例参考了graphql-java-servlet的官方示例代码。集成步骤如下:
- 使用
DefaultGraphQLSourceBuilder
创建GraphQLSource
; - 创建graphql-java-kickstart
GraphQLConfiguration
对象时所用的GraphQL
引擎相关对象都使用GraphQLSource
对象中数据即可,主要有 queryExecutionStrategy、Instrumentation、GraphQLSchema 和 PreparsedDocumentProvider。
这是官方示例上添加计算能力的代码改动,完整代码见graphql-calculator-samples。
private GraphQLConfigurationProvider() {
/**
* step 1: 使用 graphql calculator 生成GraphQL计算执行引擎
*/
DefaultGraphQLSourceBuilder graphqlSourceBuilder = new DefaultGraphQLSourceBuilder();
GraphQLSource source = graphqlSourceBuilder
.wrapperConfig(DefaultConfig.newConfig().build())
// 原始 Schema
.originalSchema(createSchema())
// 建议使用 CalculatorDocumentCachedProvider 实现类
.preparsedDocumentProvider(new DocumentParseAndValidationCache())
.build();
/**
* step 2:
* 创建 GraphQLConfiguration 用的 graphql相关对象,使用 'GraphQLSource source' 中的数据;
* 主要有 queryExecutionStrategy、Instrumentation、GraphQLSchema 和 PreparsedDocumentProvider
*
*/
GraphQLQueryInvoker queryInvoker = GraphQLQueryInvoker.newBuilder()
.withExecutionStrategyProvider(
new DefaultExecutionStrategyProvider(
source.getGraphQL().getQueryStrategy(),
source.getGraphQL().getMutationStrategy(),
source.getGraphQL().getSubscriptionStrategy()))
// calculator source
.withInstrumentation(source.getGraphQL().getInstrumentation())
// calculator source
.withPreparsedDocumentProvider(source.getGraphQL().getPreparsedDocumentProvider())
.build();
configuration = GraphQLConfiguration.
// calculator source
with(source.getWrappedSchema())
.with(queryInvoker)
.build();
}
from graphql-calculator.
Related Issues (20)
- @distinct: returns a list consisting of the distinct elements of the annotated list field HOT 1
- 添加方便用户使用graphql-java的工具类
- 在校验结果中明确计算指令变量不可使用请求变量
- 升级graphql-java核心库
- 自定义指令
- 添加辅助计算的 Scalar
- 让用户可自定义校验规则
- Wanted: 欢迎使用该组件的用户在此注册
- log debug
- uniqueJoin
- 自定义指令语法校验错误类型
- 扩展配置能力:让用户为指令指定不同的表达式引擎,不指定则使用默认引擎
- [New Feature] @partition(size: Int) on ARGUMENT_DEFINITION
- 在查询上定义 最大深度
- 修改包路径
- 有与netflix dgs 集成的案例吗 HOT 3
- Support spring-graphql HOT 2
- 指令支持对象参数字段
- DataFetcherDefinition.isAsyncFetcher 永远为false HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-calculator.