use of graphql.language.EnumValueDefinition in project graphql-java by graphql-java.
the class GraphqlAntlrToLanguage method visitEnumValueDefinition.
@Override
public Void visitEnumValueDefinition(GraphqlParser.EnumValueDefinitionContext ctx) {
EnumValueDefinition def = new EnumValueDefinition(ctx.enumValue().getText());
newNode(def, ctx);
def.setDescription(newDescription(ctx.description()));
for (ContextEntry contextEntry : contextStack) {
if (contextEntry.contextProperty == ContextProperty.EnumTypeDefinition) {
((EnumTypeDefinition) contextEntry.value).getEnumValueDefinitions().add(def);
break;
}
}
addContextProperty(ContextProperty.EnumValueDefinition, def);
super.visitChildren(ctx);
popContext();
return null;
}
use of graphql.language.EnumValueDefinition in project graphql-java by graphql-java.
the class GraphqlAntlrToLanguage method visitDirective.
@Override
public Void visitDirective(GraphqlParser.DirectiveContext ctx) {
Directive directive = new Directive(ctx.name().getText());
newNode(directive, ctx);
for (ContextEntry contextEntry : contextStack) {
if (contextEntry.contextProperty == ContextProperty.Field) {
((Field) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.FragmentDefinition) {
((FragmentDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.FragmentSpread) {
((FragmentSpread) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.InlineFragment) {
((InlineFragment) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.OperationDefinition) {
((OperationDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.EnumValueDefinition) {
((EnumValueDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.FieldDefinition) {
((FieldDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.InputValueDefinition) {
((InputValueDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.InterfaceTypeDefinition) {
((InterfaceTypeDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.EnumTypeDefinition) {
((EnumTypeDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.ObjectTypeDefinition) {
((ObjectTypeDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.ScalarTypeDefinition) {
((ScalarTypeDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.UnionTypeDefinition) {
((UnionTypeDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.InputObjectTypeDefinition) {
((InputObjectTypeDefinition) contextEntry.value).getDirectives().add(directive);
break;
} else if (contextEntry.contextProperty == ContextProperty.SchemaDefinition) {
((SchemaDefinition) contextEntry.value).getDirectives().add(directive);
break;
}
}
addContextProperty(ContextProperty.Directive, directive);
super.visitDirective(ctx);
popContext();
return null;
}
use of graphql.language.EnumValueDefinition in project graphql-java by graphql-java.
the class SchemaDiff method checkEnumType.
private void checkEnumType(DiffCtx ctx, EnumTypeDefinition oldDef, EnumTypeDefinition newDef) {
Map<String, EnumValueDefinition> oldDefinitionMap = sortedMap(oldDef.getEnumValueDefinitions(), EnumValueDefinition::getName);
Map<String, EnumValueDefinition> newDefinitionMap = sortedMap(newDef.getEnumValueDefinitions(), EnumValueDefinition::getName);
for (String enumName : oldDefinitionMap.keySet()) {
EnumValueDefinition oldEnum = oldDefinitionMap.get(enumName);
Optional<EnumValueDefinition> newEnum = Optional.ofNullable(newDefinitionMap.get(enumName));
if (!newEnum.isPresent()) {
ctx.report(DiffEvent.apiBreakage().category(DiffCategory.MISSING).typeName(oldDef.getName()).typeKind(getTypeKind(oldDef)).components(oldEnum.getName()).reasonMsg("The new API is missing an enum value '%s'", oldEnum.getName()).build());
} else {
checkDirectives(ctx, oldDef, oldEnum.getDirectives(), newEnum.get().getDirectives());
}
}
for (String enumName : newDefinitionMap.keySet()) {
EnumValueDefinition oldEnum = oldDefinitionMap.get(enumName);
if (oldEnum == null) {
ctx.report(DiffEvent.apiDanger().category(DiffCategory.ADDITION).typeName(oldDef.getName()).typeKind(getTypeKind(oldDef)).components(enumName).reasonMsg("The new API has added a new enum value '%s'", enumName).build());
}
}
checkDirectives(ctx, oldDef, newDef);
}
Aggregations