public NonUniqueDirectiveError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition, String directiveName) { super(typeDefinition, format("The '%s' type with enum value '%s' %s has declared a directive with a non unique name '%s'", typeDefinition.getName(), enumValueDefinition.getName(), lineCol(typeDefinition), directiveName)); }
public InvalidDeprecationDirectiveError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition) { super(typeDefinition, format("The %s type with enum value '%s' %s has declared an invalid deprecation directive. Its must be @deprecated(reason : \"xyz\")", typeDefinition.getName(), enumValueDefinition.getName(), lineCol(typeDefinition))); }
public NonUniqueNameError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition) { super(typeDefinition, format("The type '%s' %s has declared an enum value with a non unique name '%s'", typeDefinition.getName(), lineCol(typeDefinition), enumValueDefinition.getName())); }
public NonUniqueArgumentError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition, String argumentName) { super(typeDefinition, format("The '%s' type with enum value '%s' %s has declared an argument with a non unique name '%s'", typeDefinition.getName(), enumValueDefinition.getName(), lineCol(typeDefinition), argumentName)); }
private void checkForEnumValueRedefinition(List<GraphQLError> errors, TypeDefinition typeDefinition, List<EnumValueDefinition> enumValueDefinitions, List<EnumValueDefinition> referenceEnumValueDefinitions) { Map<String, EnumValueDefinition> referenceMap = FpKit.getByName(referenceEnumValueDefinitions, EnumValueDefinition::getName, mergeFirst()); enumValueDefinitions.forEach(fld -> { if (referenceMap.containsKey(fld.getName())) { errors.add(new TypeExtensionEnumValueRedefinitionError(typeDefinition, fld)); } }); }
private void checkArgValueMatchesAllowedEnum(List<GraphQLError> errors, Value instanceValue, EnumTypeDefinition allowedTypeDefinition) { if (!(instanceValue instanceof EnumValue)) { addValidationError(errors, EXPECTED_ENUM_MESSAGE, instanceValue.getClass().getSimpleName()); return; } EnumValue enumValue = ((EnumValue) instanceValue); boolean noneMatchAllowedEnumValue = allowedTypeDefinition.getEnumValueDefinitions().stream() .noneMatch(enumAllowedValue -> enumAllowedValue.getName().equals(enumValue.getName())); if (noneMatchAllowedEnumValue) { addValidationError(errors, MUST_BE_VALID_ENUM_VALUE_MESSAGE, enumValue.getName(), allowedTypeDefinition.getEnumValueDefinitions().stream() .map(EnumValueDefinition::getName) .collect(Collectors.joining(","))); } }
public TypeExtensionEnumValueRedefinitionError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition) { super(typeDefinition, format("'%s' extension type %s tried to redefine enum value '%s' %s", typeDefinition.getName(), BaseError.lineCol(typeDefinition), enumValueDefinition.getName(), BaseError.lineCol(enumValueDefinition) )); } }
private NodePrinter<EnumValueDefinition> enumValueDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( node.getName(), directives(node.getDirectives()) )); }; }
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(); }
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 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())); } }
public InvalidDeprecationDirectiveError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition) { super(typeDefinition, format("The %s type with enum value '%s' %s has declared an invalid deprecation directive. Its must be @deprecated(reason : \"xyz\")", typeDefinition.getName(), enumValueDefinition.getName(), lineCol(typeDefinition))); }
private List<Field> getFields(EnumTypeDefinition def) { List<Field> fields = new ArrayList<Field>(); for ( EnumValueDefinition fieldDef : def.getEnumValueDefinitions() ) { fields.add(new Field(fieldDef.getName(), null)); } return fields; }
public NonUniqueDirectiveError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition, String directiveName) { super(typeDefinition, format("The '%s' type with enum value '%s' %s has declared a directive with a non unique name '%s'", typeDefinition.getName(), enumValueDefinition.getName(), lineCol(typeDefinition), directiveName)); }
public NonUniqueArgumentError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition, String argumentName) { super(typeDefinition, format("The '%s' type with enum value '%s' %s has declared an argument with a non unique name '%s'", typeDefinition.getName(), enumValueDefinition.getName(), lineCol(typeDefinition), argumentName)); }
private void checkForEnumValueRedefinition(List<GraphQLError> errors, TypeDefinition typeDefinition, List<EnumValueDefinition> enumValueDefinitions, List<EnumValueDefinition> referenceEnumValueDefinitions) { Map<String, EnumValueDefinition> referenceMap = FpKit.getByName(referenceEnumValueDefinitions, EnumValueDefinition::getName, mergeFirst()); enumValueDefinitions.forEach(fld -> { if (referenceMap.containsKey(fld.getName())) { errors.add(new TypeExtensionEnumValueRedefinitionError(typeDefinition, fld)); } }); }
public TypeExtensionEnumValueRedefinitionError(TypeDefinition typeDefinition, EnumValueDefinition enumValueDefinition) { super(typeDefinition, format("'%s' extension type %s tried to redefine enum value '%s' %s", typeDefinition.getName(), BaseError.lineCol(typeDefinition), enumValueDefinition.getName(), BaseError.lineCol(enumValueDefinition) )); } }
private NodePrinter<EnumValueDefinition> enumValueDefinition() { return (out, node) -> { out.printf("%s", comments(node)); out.printf("%s", spaced( node.getName(), directives(node.getDirectives()) )); }; }
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(); }