private void checkInterfaceType(DiffCtx ctx, InterfaceTypeDefinition oldDef, InterfaceTypeDefinition newDef) { Map<String, FieldDefinition> oldFields = sortedMap(oldDef.getFieldDefinitions(), FieldDefinition::getName); Map<String, FieldDefinition> newFields = sortedMap(newDef.getFieldDefinitions(), FieldDefinition::getName); checkFields(ctx, oldDef, oldFields, newDef, newFields); checkDirectives(ctx, oldDef, newDef); }
private NodePrinter<InterfaceTypeDefinition> interfaceTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "interface", node.getName(), directives(node.getDirectives()), block(node.getFieldDefinitions()) ) ); }; }
List<FieldDefinition> fields = interfaceType.getFieldDefinitions();
@Override public TraversalControl visitInterfaceTypeDefinition(InterfaceTypeDefinition node, TraverserContext<Node> context) { InterfaceTypeDefinition changedNode = node.transform(builder -> { builder.directives(sort(node.getDirectives(), comparing(Directive::getName))); builder.definitions(sort(node.getFieldDefinitions(), comparing(FieldDefinition::getName))); }); return changeNode(context, changedNode); }
private void checkFieldsAreSensible(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry) { Map<String, TypeDefinition> typesMap = typeRegistry.types(); // objects List<ObjectTypeDefinition> objectTypes = filterTo(typesMap, ObjectTypeDefinition.class); objectTypes.forEach(objectType -> checkObjTypeFields(errors, objectType, objectType.getFieldDefinitions())); // interfaces List<InterfaceTypeDefinition> interfaceTypes = filterTo(typesMap, InterfaceTypeDefinition.class); interfaceTypes.forEach(interfaceType -> checkInterfaceFields(errors, interfaceType, interfaceType.getFieldDefinitions())); // enum types List<EnumTypeDefinition> enumTypes = filterTo(typesMap, EnumTypeDefinition.class); enumTypes.forEach(enumType -> checkEnumValues(errors, enumType, enumType.getEnumValueDefinitions())); // input types List<InputObjectTypeDefinition> inputTypes = filterTo(typesMap, InputObjectTypeDefinition.class); inputTypes.forEach(inputType -> checkInputValues(errors, inputType, inputType.getInputValueDefinitions())); }
)); interfaceTypeDef.getFieldDefinitions().forEach(interfaceFieldDef -> { FieldDefinition objectFieldDef = objectFields.get(interfaceFieldDef.getName()); if (objectFieldDef == null) {
private Builder(InterfaceTypeDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.description = existing.getDescription(); this.directives = existing.getDirectives(); this.definitions = existing.getFieldDefinitions(); this.ignoredChars = existing.getIgnoredChars(); }
private void checkDirectives(DirectiveLocation expectedLocation, List<GraphQLError> errors, TypeDefinition<?> typeDef) { checkDirectives(expectedLocation, errors, typeRegistry, typeDef, typeDef.getName(), typeDef.getDirectives()); if (typeDef instanceof ObjectTypeDefinition) { List<FieldDefinition> fieldDefinitions = ((ObjectTypeDefinition) typeDef).getFieldDefinitions(); checkFieldsDirectives(errors, typeRegistry, fieldDefinitions); } if (typeDef instanceof InterfaceTypeDefinition) { List<FieldDefinition> fieldDefinitions = ((InterfaceTypeDefinition) typeDef).getFieldDefinitions(); checkFieldsDirectives(errors, typeRegistry, fieldDefinitions); } if (typeDef instanceof EnumTypeDefinition) { List<EnumValueDefinition> enumValueDefinitions = ((EnumTypeDefinition) typeDef).getEnumValueDefinitions(); enumValueDefinitions.forEach(definition -> checkDirectives(ENUM_VALUE, errors, typeRegistry, definition, definition.getName(), definition.getDirectives())); } if (typeDef instanceof InputObjectTypeDefinition) { List<InputValueDefinition> inputValueDefinitions = ((InputObjectTypeDefinition) typeDef).getInputValueDefinitions(); inputValueDefinitions.forEach(definition -> checkDirectives(INPUT_FIELD_DEFINITION, errors, typeRegistry, definition, definition.getName(), definition.getDirectives())); } }
baseTypeOpt.ifPresent(baseTypeDef -> checkForFieldRedefinition(errors, extension, fieldDefinitions, baseTypeDef.getFieldDefinitions())); }); });
typeDefinition.getFieldDefinitions().forEach(fieldDef -> { FieldDefAndDirectiveParams fieldAndParams = buildField(buildCtx, typeDefinition, fieldDef); builder.field(fieldAndParams.fieldDefinition);
private void checkInterfaceType(DiffCtx ctx, InterfaceTypeDefinition oldDef, InterfaceTypeDefinition newDef) { Map<String, FieldDefinition> oldFields = sortedMap(oldDef.getFieldDefinitions(), FieldDefinition::getName); Map<String, FieldDefinition> newFields = sortedMap(newDef.getFieldDefinitions(), FieldDefinition::getName); checkFields(ctx, oldDef, oldFields, newDef, newFields); checkDirectives(ctx, oldDef, newDef); }
private void addImports(Collection<String> imports, InterfaceTypeDefinition def) { for ( FieldDefinition fieldDef : def.getFieldDefinitions() ) { addImports(imports, fieldDef.getType()); } }
private List<Field> getFields(InterfaceTypeDefinition def) { List<Field> fields = new ArrayList<Field>(); for ( FieldDefinition fieldDef : def.getFieldDefinitions() ) { Field field = new Field(fieldDef.getName(), toJavaTypeName(fieldDef.getType())); field.args = toArgs(fieldDef.getInputValueDefinitions()); fields.add(field); } return fields; }
private NodePrinter<InterfaceTypeDefinition> interfaceTypeDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( "interface", node.getName(), directives(node.getDirectives()), block(node.getFieldDefinitions()) ) ); }; }
List<FieldDefinition> fields = interfaceType.getFieldDefinitions();
@Override public TraversalControl visitInterfaceTypeDefinition(InterfaceTypeDefinition node, TraverserContext<Node> context) { InterfaceTypeDefinition changedNode = node.transform(builder -> { builder.directives(sort(node.getDirectives(), comparing(Directive::getName))); builder.definitions(sort(node.getFieldDefinitions(), comparing(FieldDefinition::getName))); }); return changeNode(context, changedNode); }
private void checkFieldsAreSensible(List<GraphQLError> errors, TypeDefinitionRegistry typeRegistry) { Map<String, TypeDefinition> typesMap = typeRegistry.types(); // objects List<ObjectTypeDefinition> objectTypes = filterTo(typesMap, ObjectTypeDefinition.class); objectTypes.forEach(objectType -> checkObjTypeFields(errors, objectType, objectType.getFieldDefinitions())); // interfaces List<InterfaceTypeDefinition> interfaceTypes = filterTo(typesMap, InterfaceTypeDefinition.class); interfaceTypes.forEach(interfaceType -> checkInterfaceFields(errors, interfaceType, interfaceType.getFieldDefinitions())); // enum types List<EnumTypeDefinition> enumTypes = filterTo(typesMap, EnumTypeDefinition.class); enumTypes.forEach(enumType -> checkEnumValues(errors, enumType, enumType.getEnumValueDefinitions())); // input types List<InputObjectTypeDefinition> inputTypes = filterTo(typesMap, InputObjectTypeDefinition.class); inputTypes.forEach(inputType -> checkInputValues(errors, inputType, inputType.getInputValueDefinitions())); }
private Builder(InterfaceTypeDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.description = existing.getDescription(); this.directives = existing.getDirectives(); this.definitions = existing.getFieldDefinitions(); this.ignoredChars = existing.getIgnoredChars(); }
private void checkDirectives(DirectiveLocation expectedLocation, List<GraphQLError> errors, TypeDefinition<?> typeDef) { checkDirectives(expectedLocation, errors, typeRegistry, typeDef, typeDef.getName(), typeDef.getDirectives()); if (typeDef instanceof ObjectTypeDefinition) { List<FieldDefinition> fieldDefinitions = ((ObjectTypeDefinition) typeDef).getFieldDefinitions(); checkFieldsDirectives(errors, typeRegistry, fieldDefinitions); } if (typeDef instanceof InterfaceTypeDefinition) { List<FieldDefinition> fieldDefinitions = ((InterfaceTypeDefinition) typeDef).getFieldDefinitions(); checkFieldsDirectives(errors, typeRegistry, fieldDefinitions); } if (typeDef instanceof EnumTypeDefinition) { List<EnumValueDefinition> enumValueDefinitions = ((EnumTypeDefinition) typeDef).getEnumValueDefinitions(); enumValueDefinitions.forEach(definition -> checkDirectives(ENUM_VALUE, errors, typeRegistry, definition, definition.getName(), definition.getDirectives())); } if (typeDef instanceof InputObjectTypeDefinition) { List<InputValueDefinition> inputValueDefinitions = ((InputObjectTypeDefinition) typeDef).getInputValueDefinitions(); inputValueDefinitions.forEach(definition -> checkDirectives(INPUT_FIELD_DEFINITION, errors, typeRegistry, definition, definition.getName(), definition.getDirectives())); } }
baseTypeOpt.ifPresent(baseTypeDef -> checkForFieldRedefinition(errors, extension, fieldDefinitions, baseTypeDef.getFieldDefinitions())); }); });