public Builder(GraphQLInputObjectType existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.definition = existing.getDefinition(); this.fields.putAll(getByName(existing.getFields(), GraphQLInputObjectField::getName)); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
private static Value handleInputObject(Object _value, GraphQLInputObjectType type) { Map mapValue = objToMap(_value); List<GraphQLInputObjectField> fields = type.getFields(); List<ObjectField> fieldNodes = new ArrayList<>(); fields.forEach(field -> { GraphQLInputType fieldType = field.getType(); Value nodeValue = astFromValue(mapValue.get(field.getName()), fieldType); if (nodeValue != null) { fieldNodes.add(ObjectField.newObjectField().name(field.getName()).value(nodeValue).build()); } }); return ObjectValue.newObjectValue().objectFields(fieldNodes).build(); }
public Builder(GraphQLInputObjectType existing) { this.name = existing.getName(); this.description = existing.getDescription(); this.definition = existing.getDefinition(); this.fields.putAll(getByName(existing.getFields(), GraphQLInputObjectField::getName)); this.directives.putAll(getByName(existing.getDirectives(), GraphQLDirective::getName)); }
private static Value handleInputObject(Object _value, GraphQLInputObjectType type) { Map mapValue = objToMap(_value); List<GraphQLInputObjectField> fields = type.getFields(); List<ObjectField> fieldNodes = new ArrayList<>(); fields.forEach(field -> { GraphQLInputType fieldType = field.getType(); Value nodeValue = astFromValue(mapValue.get(field.getName()), fieldType); if (nodeValue != null) { fieldNodes.add(ObjectField.newObjectField().name(field.getName()).value(nodeValue).build()); } }); return ObjectValue.newObjectValue().objectFields(fieldNodes).build(); }
objectName, ((GraphQLInputObjectType) attributeType).getDescription(), ((GraphQLInputObjectType) attributeType).getFields() ); convertedInputs.put(objectName, wrappedType);
objectName, ((GraphQLInputObjectType) attributeType).getDescription(), ((GraphQLInputObjectType) attributeType).getFields() ); convertedInputs.put(objectName, wrappedType);
@Test public void inputObject() { GraphQLObjectInfoRetriever graphQLObjectInfoRetriever = new GraphQLObjectInfoRetriever(); GraphQLInputObjectType type = new InputObjectBuilder(graphQLObjectInfoRetriever, new ParentalSearch(graphQLObjectInfoRetriever), new BreadthFirstSearch(graphQLObjectInfoRetriever), new GraphQLFieldRetriever()). getInputObjectBuilder(InputObject.class, GraphQLAnnotations.getInstance().getContainer()).build(); assertEquals(type.getName(), DEFAULT_INPUT_PREFIX + InputObject.class.getSimpleName(), "Type name prefix did not match expected value"); assertEquals(type.getFields().size(), InputObject.class.getDeclaredFields().length); }
@Test public void inputObjectCustomPrefixes() { GraphQLObjectInfoRetriever graphQLObjectInfoRetriever = new GraphQLObjectInfoRetriever(); ProcessingElementsContainer container = GraphQLAnnotations.getInstance().getContainer(); container.setInputPrefix(""); container.setInputSuffix("Input"); GraphQLInputObjectType type = new InputObjectBuilder(graphQLObjectInfoRetriever, new ParentalSearch(graphQLObjectInfoRetriever), new BreadthFirstSearch(graphQLObjectInfoRetriever), new GraphQLFieldRetriever()). getInputObjectBuilder(InputObject.class, GraphQLAnnotations.getInstance().getContainer()).build(); assertEquals(type.getName(), "" + InputObject.class.getSimpleName() + "Input", "Type name prefix did not match expected value"); assertEquals(type.getFields().size(), InputObject.class.getDeclaredFields().length); container.setInputPrefix(DEFAULT_INPUT_PREFIX); container.setInputSuffix(DEFAULT_INPUT_SUFFIX); }