private NodePrinter<EnumValueDefinition> enumValueDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( node.getName(), directives(node.getDirectives()) )); }; }
private void checkEnumValues(List<GraphQLError> errors, EnumTypeDefinition enumType, List<EnumValueDefinition> enumValueDefinitions) { // enum unique ness checkNamedUniqueness(errors, enumValueDefinitions, EnumValueDefinition::getName, (name, inputValueDefinition) -> new NonUniqueNameError(enumType, inputValueDefinition)); // directive checks enumValueDefinitions.forEach(enumValue -> { BiFunction<String, Directive, NonUniqueDirectiveError> errorFunction = (directiveName, directive) -> new NonUniqueDirectiveError(enumType, enumValue, directiveName); checkNamedUniqueness(errors, enumValue.getDirectives(), Directive::getName, errorFunction); }); enumValueDefinitions.forEach(enumValue -> enumValue.getDirectives().forEach(directive -> { checkDeprecatedDirective(errors, directive, () -> new InvalidDeprecationDirectiveError(enumType, enumValue)); BiFunction<String, Argument, NonUniqueArgumentError> errorFunction = (argumentName, argument) -> new NonUniqueArgumentError(enumType, enumValue, argumentName); checkNamedUniqueness(errors, directive.getArguments(), Argument::getName, errorFunction); })); }
private Builder(EnumValueDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.description = existing.getDescription(); this.directives = existing.getDirectives(); this.ignoredChars = existing.getIgnoredChars(); }
.build()); } else { checkDirectives(ctx, oldDef, oldEnum.getDirectives(), newEnum.get().getDirectives());
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())); } }
private GraphQLEnumValueDefinition buildEnumValue(BuildContext buildCtx, EnumTypeDefinition typeDefinition, EnumValuesProvider enumValuesProvider, EnumValueDefinition evd) { buildCtx.enterNode(evd); String description = schemaGeneratorHelper.buildDescription(evd, evd.getDescription()); String deprecation = schemaGeneratorHelper.buildDeprecationReason(evd.getDirectives()); Object value; if (enumValuesProvider != null) { value = enumValuesProvider.getValue(evd.getName()); assertNotNull(value, "EnumValuesProvider for %s returned null for %s", typeDefinition.getName(), evd.getName()); } else { value = evd.getName(); } GraphQLEnumValueDefinition valueDefinition = newEnumValueDefinition() .name(evd.getName()) .value(value) .description(description) .deprecationReason(deprecation) .withDirectives( buildDirectives(evd.getDirectives(), emptyList(), ENUM_VALUE, buildCtx.getDirectiveDefinitions()) ) .build(); valueDefinition = directiveBehaviour.onEnumValue(valueDefinition, buildCtx.mkBehaviourParams()); return buildCtx.exitNode(valueDefinition); }
private NodePrinter<EnumValueDefinition> enumValueDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( node.getName(), directives(node.getDirectives()) )); }; }
private void checkEnumValues(List<GraphQLError> errors, EnumTypeDefinition enumType, List<EnumValueDefinition> enumValueDefinitions) { // enum unique ness checkNamedUniqueness(errors, enumValueDefinitions, EnumValueDefinition::getName, (name, inputValueDefinition) -> new NonUniqueNameError(enumType, inputValueDefinition)); // directive checks enumValueDefinitions.forEach(enumValue -> { BiFunction<String, Directive, NonUniqueDirectiveError> errorFunction = (directiveName, directive) -> new NonUniqueDirectiveError(enumType, enumValue, directiveName); checkNamedUniqueness(errors, enumValue.getDirectives(), Directive::getName, errorFunction); }); enumValueDefinitions.forEach(enumValue -> enumValue.getDirectives().forEach(directive -> { checkDeprecatedDirective(errors, directive, () -> new InvalidDeprecationDirectiveError(enumType, enumValue)); BiFunction<String, Argument, NonUniqueArgumentError> errorFunction = (argumentName, argument) -> new NonUniqueArgumentError(enumType, enumValue, argumentName); checkNamedUniqueness(errors, directive.getArguments(), Argument::getName, errorFunction); })); }
private Builder(EnumValueDefinition existing) { this.sourceLocation = existing.getSourceLocation(); this.comments = existing.getComments(); this.name = existing.getName(); this.description = existing.getDescription(); this.directives = existing.getDirectives(); this.ignoredChars = existing.getIgnoredChars(); }
.build()); } else { checkDirectives(ctx, oldDef, oldEnum.getDirectives(), newEnum.get().getDirectives());
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())); } }
private GraphQLEnumValueDefinition buildEnumValue(BuildContext buildCtx, EnumTypeDefinition typeDefinition, EnumValuesProvider enumValuesProvider, EnumValueDefinition evd) { buildCtx.enterNode(evd); String description = schemaGeneratorHelper.buildDescription(evd, evd.getDescription()); String deprecation = schemaGeneratorHelper.buildDeprecationReason(evd.getDirectives()); Object value; if (enumValuesProvider != null) { value = enumValuesProvider.getValue(evd.getName()); assertNotNull(value, "EnumValuesProvider for %s returned null for %s", typeDefinition.getName(), evd.getName()); } else { value = evd.getName(); } GraphQLEnumValueDefinition valueDefinition = newEnumValueDefinition() .name(evd.getName()) .value(value) .description(description) .deprecationReason(deprecation) .withDirectives( buildDirectives(evd.getDirectives(), emptyList(), ENUM_VALUE, buildCtx.getDirectiveDefinitions()) ) .build(); valueDefinition = directiveBehaviour.onEnumValue(valueDefinition, buildCtx.mkBehaviourParams()); return buildCtx.exitNode(valueDefinition); }