graphql
weixin_40455124
这个作者很懒,什么都没留下…
展开
-
Graphql FieldVisibility
Graphql 除了通过instrument修改返回外,也可以通过FieldVisibility来进行控制,官方示意代码是通过emptyList不返回,关键代码如下:@Override public List<GraphQLFieldDefinition> getFieldDefinitions(GraphQLFieldsContainer fieldsContainer) { if ("AdminType".equals(fieldsContain原创 2020-09-09 08:23:15 · 197 阅读 · 0 评论 -
GraphQLQueryResolver 多实例
kickstart 的spring boot 已经支持多实例了,即支持使用component模式定义多个GraphQLQueryResolver 及GraphQLMutationResolver@Componentclass Query2 implements GraphQLQueryResolver {@Componentpublic class Mutation implements GraphQLMutationResolver {...原创 2020-09-08 22:23:00 · 767 阅读 · 0 评论 -
Graphql Instrumentation
Instrumentation 包括系统默认及自定义两部分,如果是kickstart的boot实现,默认Instrumentation,可以参考GraphQLInstrumentationAutoConfiguration类,以下是这个类的代码:@Configuration@ConditionalOnClass(MetricsAutoConfiguration.class)@AutoConfigureAfter({MetricsAutoConfiguration.class, SimpleMetric原创 2020-09-08 22:19:52 · 423 阅读 · 0 评论 -
Graphql-java GraphQLResolver及PropertyDataFetcher
graphql -java 默认支持一般的java bean的properties 读取,一般不需要使用GraphQLResolver。使用GraphQLResolver可以类似为默认对象增加使用get方法增加属性,这些新增属性(get方法)无需在原有对象上定义。如以下代码为Post对象增加一个Random String的返回@Componentclass PostResolver implements GraphQLResolver<Post> { Random r = new Ra原创 2020-09-08 22:14:21 · 808 阅读 · 0 评论 -
graphql interface 定义
graphql interface 定义只存在scheme定义上,不需要有对应java对象,同时interface也只是一种关系表现,implements 的所有field都需要列出,以下是示意代码#不需要有对应bean,只是graphql 定义interface PostInterface{ id: ID! text: String comments: [Comment!]! } #implements 所有field 需要重新写一遍,不能漏#GraphQL原创 2020-09-08 22:08:00 · 398 阅读 · 0 评论 -
graphql java 自定义scalar
GraphQLScalarType ,可以理解为java 语言中的类型、对象。可以通过extends GraphQLScalarType实现自定义。自定义分为两部分:java 代码scheme 定义java 代码如下@Componentpublic class MyStringScalarType extends GraphQLScalarType { private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm";原创 2020-09-08 22:05:23 · 411 阅读 · 0 评论 -
graphql java client
kickstart 有一个client 的spring boot 包,只需要引入:implementation “com.graphql-java-kickstart:graphql-webclient-spring-boot-starter:0.2.0”非spring boot的reactive模式代码如下package com.graphql.sample.boot;import java.util.HashMap;import java.util.Map;import org.spri原创 2020-09-08 22:00:29 · 537 阅读 · 0 评论