Search in sources :

Example 11 with FieldDefinition

use of graphql.language.FieldDefinition in project graphql-java by graphql-java.

the class GraphqlAntlrToLanguage method visitListType.

@Override
public Void visitListType(GraphqlParser.ListTypeContext ctx) {
    ListType listType = new ListType();
    newNode(listType, ctx);
    for (ContextEntry contextEntry : contextStack) {
        if (contextEntry.value instanceof ListType) {
            ((ListType) contextEntry.value).setType(listType);
            break;
        }
        if (contextEntry.value instanceof NonNullType) {
            ((NonNullType) contextEntry.value).setType(listType);
            break;
        }
        if (contextEntry.value instanceof VariableDefinition) {
            ((VariableDefinition) contextEntry.value).setType(listType);
            break;
        }
        if (contextEntry.value instanceof FieldDefinition) {
            ((FieldDefinition) contextEntry.value).setType(listType);
            break;
        }
        if (contextEntry.value instanceof InputValueDefinition) {
            ((InputValueDefinition) contextEntry.value).setType(listType);
            break;
        }
    }
    addContextProperty(ContextProperty.ListType, listType);
    super.visitListType(ctx);
    popContext();
    return null;
}
Also used : VariableDefinition(graphql.language.VariableDefinition) NonNullType(graphql.language.NonNullType) ListType(graphql.language.ListType) FieldDefinition(graphql.language.FieldDefinition) InputValueDefinition(graphql.language.InputValueDefinition)

Example 12 with FieldDefinition

use of graphql.language.FieldDefinition in project graphql-java by graphql-java.

the class SchemaDiff method checkFieldAdditions.

private void checkFieldAdditions(DiffCtx ctx, TypeDefinition newDef, Map<String, FieldDefinition> oldFields, Map<String, FieldDefinition> newFields) {
    for (Map.Entry<String, FieldDefinition> entry : newFields.entrySet()) {
        String fieldName = entry.getKey();
        ctx.report(DiffEvent.apiInfo().typeName(newDef.getName()).typeKind(getTypeKind(newDef)).fieldName(fieldName).reasonMsg("\tExamining field '%s' ...", mkDotName(newDef.getName(), fieldName)).build());
        FieldDefinition oldField = oldFields.get(fieldName);
        if (oldField == null) {
            ctx.report(DiffEvent.apiInfo().category(DiffCategory.ADDITION).typeName(newDef.getName()).typeKind(getTypeKind(newDef)).fieldName(fieldName).reasonMsg("The new API adds the field '%s'", mkDotName(newDef.getName(), fieldName)).build());
        }
    }
}
Also used : FieldDefinition(graphql.language.FieldDefinition) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

FieldDefinition (graphql.language.FieldDefinition)12 InputValueDefinition (graphql.language.InputValueDefinition)8 Map (java.util.Map)7 TypeName (graphql.language.TypeName)5 List (java.util.List)5 GraphQLError (graphql.GraphQLError)4 Internal (graphql.Internal)4 Argument (graphql.language.Argument)4 AstPrinter (graphql.language.AstPrinter)4 Directive (graphql.language.Directive)4 EnumTypeDefinition (graphql.language.EnumTypeDefinition)4 EnumValueDefinition (graphql.language.EnumValueDefinition)4 InputObjectTypeDefinition (graphql.language.InputObjectTypeDefinition)4 InterfaceTypeDefinition (graphql.language.InterfaceTypeDefinition)4 ObjectTypeDefinition (graphql.language.ObjectTypeDefinition)4 Type (graphql.language.Type)4 TypeDefinition (graphql.language.TypeDefinition)4 UnionTypeDefinition (graphql.language.UnionTypeDefinition)4 InvalidDeprecationDirectiveError (graphql.schema.idl.errors.InvalidDeprecationDirectiveError)4 MissingTypeError (graphql.schema.idl.errors.MissingTypeError)4