热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

graphql.schema.GraphQLNonNull.getWrappedType()方法的使用及代码示例

本文整理了Java中graphql.schema.GraphQLNonNull.getWrappedType()方法的一些代码示例,展示了GraphQLNo

本文整理了Java中graphql.schema.GraphQLNonNull.getWrappedType()方法的一些代码示例,展示了GraphQLNonNull.getWrappedType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GraphQLNonNull.getWrappedType()方法的具体详情如下:
包路径:graphql.schema.GraphQLNonNull
类名称:GraphQLNonNull
方法名:getWrappedType

GraphQLNonNull.getWrappedType介绍

暂无

代码示例

代码示例来源:origin: graphql-java/graphql-java

private static Value handleNonNull(Object _value, GraphQLNonNull type) {
GraphQLType wrappedType = type.getWrappedType();
return astFromValue(_value, wrappedType);
}

代码示例来源:origin: graphql-java/graphql-java

private GraphQLType unwrapNonNull(GraphQLNonNull type) {
if (isList(type.getWrappedType())) {
//we only care about [type!]! i.e. non-null lists of non-nulls
GraphQLList listType = (GraphQLList) type.getWrappedType();
if (isNonNull(listType.getWrappedType())) {
return unwrapAll(listType.getWrappedType());
} else {
return type.getWrappedType();
}
} else {
return unwrapAll(type.getWrappedType());
}
}

代码示例来源:origin: graphql-java/graphql-java

/**
* Unwraps one layer of the type or just returns the type again if its not a wrapped type
*
* @param type the type to unwrapOne
*
* @return the unwrapped type or the same type again if its not wrapped
*/
public static GraphQLType unwrapOne(GraphQLType type) {
if (isNonNull(type)) {
return ((GraphQLNonNull) type).getWrappedType();
} else if (isList(type)) {
return ((GraphQLList) type).getWrappedType();
}
return type;
}

代码示例来源:origin: leangen/graphql-spqr

public static GraphQLType unwrapNonNull(GraphQLType type) {
while (type instanceof GraphQLNonNull) {
type = ((GraphQLNonNull) type).getWrappedType();
}
return type;
}

代码示例来源:origin: com.distelli.graphql/graphql-apigen-deps

private boolean isBooleanMethod(GraphQLOutputType outputType) {
if (outputType == GraphQLBoolean) return true;
if (outputType instanceof GraphQLNonNull) {
return ((GraphQLNonNull) outputType).getWrappedType() == GraphQLBoolean;
}
return false;
}

代码示例来源:origin: Distelli/graphql-apigen

private boolean isBooleanMethod(GraphQLOutputType outputType) {
if (outputType == GraphQLBoolean) return true;
if (outputType instanceof GraphQLNonNull) {
return ((GraphQLNonNull) outputType).getWrappedType() == GraphQLBoolean;
}
return false;
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

private boolean isaBoolean() {
return outputType == GraphQLBoolean || (outputType instanceof GraphQLNonNull && ((GraphQLNonNull) outputType).getWrappedType() == GraphQLBoolean);
}

代码示例来源:origin: castlemock/castlemock

private static boolean isListable(final graphql.schema.GraphQLType type){
if(type instanceof GraphQLNonNull){
graphql.schema.GraphQLType wrappedType = ((GraphQLNonNull) type).getWrappedType();
return isListable(wrappedType);
}
return (type instanceof GraphQLList);
}

代码示例来源:origin: com.graphql-java/graphql-java

private static Value handleNonNull(Object _value, GraphQLNonNull type) {
GraphQLType wrappedType = type.getWrappedType();
return astFromValue(_value, wrappedType);
}

代码示例来源:origin: com.graphql-java/graphql-java

private GraphQLType unwrapNonNull(GraphQLNonNull type) {
if (isList(type.getWrappedType())) {
//we only care about [type!]! i.e. non-null lists of non-nulls
GraphQLList listType = (GraphQLList) type.getWrappedType();
if (isNonNull(listType.getWrappedType())) {
return unwrapAll(listType.getWrappedType());
} else {
return type.getWrappedType();
}
} else {
return unwrapAll(type.getWrappedType());
}
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

private GraphQLOutputType getGraphQLConnection(AccessibleObject field, graphql.schema.GraphQLType type, Relay relay, Map typeRegistry) {
if (type instanceof GraphQLNonNull) {
GraphQLList listType = (GraphQLList) ((GraphQLNonNull) type).getWrappedType();
return new GraphQLNonNull(internalGetGraphQLConnection(field, listType, relay, typeRegistry));
} else {
return internalGetGraphQLConnection(field, (GraphQLList) type, relay, typeRegistry);
}
}

代码示例来源:origin: castlemock/castlemock

private static graphql.schema.GraphQLType getType(final graphql.schema.GraphQLType type){
if(type instanceof GraphQLNonNull){
graphql.schema.GraphQLType wrappedType = ((GraphQLNonNull) type).getWrappedType();
return getType(wrappedType);
}
if(type instanceof GraphQLList){
graphql.schema.GraphQLType wrappedType = ((GraphQLList) type).getWrappedType();
return getType(wrappedType);
}
return type;
}

代码示例来源:origin: com.graphql-java/graphql-java

/**
* Unwraps one layer of the type or just returns the type again if its not a wrapped type
*
* @param type the type to unwrapOne
*
* @return the unwrapped type or the same type again if its not wrapped
*/
public static GraphQLType unwrapOne(GraphQLType type) {
if (isNonNull(type)) {
return ((GraphQLNonNull) type).getWrappedType();
} else if (isList(type)) {
return ((GraphQLList) type).getWrappedType();
}
return type;
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

public static boolean isConnection(AccessibleObject obj, GraphQLType type) {
if (type instanceof graphql.schema.GraphQLNonNull) {
type = ((GraphQLNonNull) type).getWrappedType();
}
final GraphQLType actualType = type;
boolean isValidGraphQLTypeForCOnnection= obj.isAnnotationPresent(GraphQLConnection.class) &&
actualType instanceof GraphQLList && TYPES_FOR_CONNECTION.stream().anyMatch(aClass ->
aClass.isInstance(((GraphQLList) actualType).getWrappedType()));
if (isValidGraphQLTypeForConnection) {
ConnectionValidator validator = newInstance(obj.getAnnotation(GraphQLConnection.class).validator());
validator.validate(obj);
return true;
} else {
return false;
}
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@Test
public void optional() throws NoSuchMethodException {
ProcessingElementsContainer cOntainer= testedProcessingElementsContainer();
graphql.schema.GraphQLType type = container.getDefaultTypeFunction().buildType(getClass().getMethod("optionalMethod").getReturnType(), getClass().getMethod("listMethod").getAnnotatedReturnType(),null);
assertTrue(type instanceof GraphQLList);
GraphQLType subtype = ((GraphQLList) type).getWrappedType();
assertTrue(subtype instanceof graphql.schema.GraphQLNonNull);
GraphQLType wrappedType = (((graphql.schema.GraphQLNonNull) subtype).getWrappedType());
assertEquals(wrappedType, GraphQLString);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

private void assertIsGraphListOfListOfString(GraphQLType type) {
assertTrue(type instanceof GraphQLList);
GraphQLList subtype = (GraphQLList) ((GraphQLList) type).getWrappedType();
assertTrue(subtype.getWrappedType() instanceof graphql.schema.GraphQLNonNull);
graphql.schema.GraphQLNonNull wrappedType = (graphql.schema.GraphQLNonNull) subtype.getWrappedType();
assertEquals(wrappedType.getWrappedType(), GraphQLString);
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

assertEquals(fields.get(2).getDescription(), "field");
assertTrue(fields.get(2).getType() instanceof graphql.schema.GraphQLNonNull);
assertEquals(((graphql.schema.GraphQLNonNull) fields.get(2).getType()).getWrappedType(), GraphQLString);
assertEquals(args.get(0).getName(), "a");
assertTrue(args.get(0).getType() instanceof graphql.schema.GraphQLNonNull);
assertEquals(((graphql.schema.GraphQLNonNull) args.get(0).getType()).getWrappedType(), GraphQLString);
assertEquals(args.get(1).getName(), "b");
assertEquals(args.get(1).getType(), GraphQLString);

代码示例来源:origin: Enigmatis/graphql-java-annotations

GraphQLInputType input = doSomethingElse.getArgument("input").getType();
assertTrue(input instanceof GraphQLNonNull);
GraphQLType inputType = ((graphql.schema.GraphQLNonNull) input).getWrappedType();
assertTrue(inputType instanceof GraphQLInputObjectType);
GraphQLInputObjectType inputType_ = (GraphQLInputObjectType) inputType;

代码示例来源:origin: Enigmatis/graphql-java-annotations

@Test
public void noArgMutation() {
GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class);
GraphQLFieldDefinition doSomething = object.getFieldDefinition("doSomething");
assertNotNull(doSomething);
assertEquals(doSomething.getArguments().size(), 1);
GraphQLInputType input = doSomething.getArgument("input").getType();
assertTrue(input instanceof GraphQLNonNull);
GraphQLType inputType = ((graphql.schema.GraphQLNonNull) input).getWrappedType();
assertTrue(inputType instanceof GraphQLInputObjectType);
assertTrue(doSomething.getType() instanceof GraphQLObjectType);
GraphQLObjectType returnType = (GraphQLObjectType) doSomething.getType();
assertNotNull(returnType.getFieldDefinition("getI"));
assertNotNull(returnType.getFieldDefinition("clientMutationId"));
GraphQLSchema schema = GraphQLSchema.newSchema().query(object).mutation(object).build();
GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build();
ExecutionResult result = graphQL.execute("mutation { doSomething(input: {clientMutationId: \"1\"}) { getI clientMutationId } }", new TestObject());
assertEquals(result.getErrors().size(), 0);
Map returns = (Map) ((Map) result.getData()).get("doSomething");
assertEquals(returns.get("getI"), 0);
assertEquals(returns.get("clientMutationId"), "1");
}

代码示例来源:origin: Enigmatis/graphql-java-annotations

@Test
public void argMutation() {
GraphQLObjectType object = GraphQLAnnotations.object(TestObject.class);
GraphQLFieldDefinition doSomethingElse = object.getFieldDefinition("doSomethingElse");
assertNotNull(doSomethingElse);
assertEquals(doSomethingElse.getArguments().size(), 1);
GraphQLInputType input = doSomethingElse.getArgument("input").getType();
assertTrue(input instanceof GraphQLNonNull);
GraphQLType inputType = ((graphql.schema.GraphQLNonNull) input).getWrappedType();
assertTrue(inputType instanceof GraphQLInputObjectType);
GraphQLInputObjectType inputType_ = (GraphQLInputObjectType) inputType;
assertNotNull(inputType_.getField("a"));
assertNotNull(inputType_.getField("b"));
assertEquals(inputType_.getField("a").getDescription(), "A");
assertTrue(doSomethingElse.getType() instanceof GraphQLObjectType);
GraphQLObjectType returnType = (GraphQLObjectType) doSomethingElse.getType();
assertNotNull(returnType.getFieldDefinition("getI"));
assertNotNull(returnType.getFieldDefinition("clientMutationId"));
GraphQLSchema schema = GraphQLSchema.newSchema().query(object).mutation(object).build();
GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build();
ExecutionResult result = graphQL.execute("mutation { doSomethingElse(input: {a: 0, b: 1, clientMutationId: \"1\"}) { getI clientMutationId } }", new TestObject());
assertEquals(result.getErrors().size(), 0);
Map returns = (Map) ((Map) result.getData()).get("doSomethingElse");
assertEquals(returns.get("getI"), -1);
assertEquals(returns.get("clientMutationId"), "1");
}

推荐阅读
author-avatar
o0沢田纲吉0o
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有