use of graphql.language.InputValueDefinition in project graphql-java by graphql-java.
the class GraphqlAntlrToLanguage method visitNonNullType.
@Override
public Void visitNonNullType(GraphqlParser.NonNullTypeContext ctx) {
NonNullType nonNullType = new NonNullType();
newNode(nonNullType, ctx);
for (ContextEntry contextEntry : contextStack) {
if (contextEntry.value instanceof ListType) {
((ListType) contextEntry.value).setType(nonNullType);
break;
}
if (contextEntry.value instanceof VariableDefinition) {
((VariableDefinition) contextEntry.value).setType(nonNullType);
break;
}
if (contextEntry.value instanceof FieldDefinition) {
((FieldDefinition) contextEntry.value).setType(nonNullType);
break;
}
if (contextEntry.value instanceof InputValueDefinition) {
((InputValueDefinition) contextEntry.value).setType(nonNullType);
break;
}
}
addContextProperty(ContextProperty.NonNullType, nonNullType);
super.visitNonNullType(ctx);
popContext();
return null;
}
use of graphql.language.InputValueDefinition in project graphql-java by graphql-java.
the class IntrospectionResultToSchema method createFields.
private List<FieldDefinition> createFields(List<Map<String, Object>> fields) {
List<FieldDefinition> result = new ArrayList<>();
for (Map<String, Object> field : fields) {
FieldDefinition fieldDefinition = new FieldDefinition((String) field.get("name"));
fieldDefinition.setComments(toComment((String) field.get("description")));
fieldDefinition.setType(createTypeIndirection((Map<String, Object>) field.get("type")));
createDeprecatedDirective(field, fieldDefinition.getDirectives());
List<Map<String, Object>> args = (List<Map<String, Object>>) field.get("args");
List<InputValueDefinition> inputValueDefinitions = createInputValueDefinitions(args);
fieldDefinition.getInputValueDefinitions().addAll(inputValueDefinitions);
result.add(fieldDefinition);
}
return result;
}
use of graphql.language.InputValueDefinition in project graphql-java by graphql-java.
the class IntrospectionResultToSchema method createInputObject.
@SuppressWarnings("unchecked")
InputObjectTypeDefinition createInputObject(Map<String, Object> input) {
assertTrue(input.get("kind").equals("INPUT_OBJECT"), "wrong input");
InputObjectTypeDefinition inputObjectTypeDefinition = new InputObjectTypeDefinition((String) input.get("name"));
inputObjectTypeDefinition.setComments(toComment((String) input.get("description")));
List<Map<String, Object>> fields = (List<Map<String, Object>>) input.get("inputFields");
List<InputValueDefinition> inputValueDefinitions = createInputValueDefinitions(fields);
inputObjectTypeDefinition.getInputValueDefinitions().addAll(inputValueDefinitions);
return inputObjectTypeDefinition;
}
use of graphql.language.InputValueDefinition in project graphql-java by graphql-java.
the class SchemaTypeChecker method checkInterfaceFields.
private void checkInterfaceFields(List<GraphQLError> errors, InterfaceTypeDefinition interfaceType, List<FieldDefinition> fieldDefinitions) {
// field unique ness
checkNamedUniqueness(errors, fieldDefinitions, FieldDefinition::getName, (name, fieldDef) -> new NonUniqueNameError(interfaceType, fieldDef));
// field arg unique ness
fieldDefinitions.forEach(fld -> checkNamedUniqueness(errors, fld.getInputValueDefinitions(), InputValueDefinition::getName, (name, inputValueDefinition) -> new NonUniqueArgumentError(interfaceType, fld, name)));
// directive checks
fieldDefinitions.forEach(fld -> checkNamedUniqueness(errors, fld.getDirectives(), Directive::getName, (directiveName, directive) -> new NonUniqueDirectiveError(interfaceType, fld, directiveName)));
fieldDefinitions.forEach(fld -> fld.getDirectives().forEach(directive -> {
checkDeprecatedDirective(errors, directive, () -> new InvalidDeprecationDirectiveError(interfaceType, fld));
checkNamedUniqueness(errors, directive.getArguments(), Argument::getName, (argumentName, argument) -> new NonUniqueArgumentError(interfaceType, fld, argumentName));
}));
}
use of graphql.language.InputValueDefinition in project graphql-java by graphql-java.
the class SchemaTypeChecker method checkObjTypeFields.
private void checkObjTypeFields(List<GraphQLError> errors, ObjectTypeDefinition typeDefinition, List<FieldDefinition> fieldDefinitions) {
// field unique ness
checkNamedUniqueness(errors, fieldDefinitions, FieldDefinition::getName, (name, fieldDef) -> new NonUniqueNameError(typeDefinition, fieldDef));
// field arg unique ness
fieldDefinitions.forEach(fld -> checkNamedUniqueness(errors, fld.getInputValueDefinitions(), InputValueDefinition::getName, (name, inputValueDefinition) -> new NonUniqueArgumentError(typeDefinition, fld, name)));
// directive checks
fieldDefinitions.forEach(fld -> checkNamedUniqueness(errors, fld.getDirectives(), Directive::getName, (directiveName, directive) -> new NonUniqueDirectiveError(typeDefinition, fld, directiveName)));
fieldDefinitions.forEach(fld -> fld.getDirectives().forEach(directive -> {
checkDeprecatedDirective(errors, directive, () -> new InvalidDeprecationDirectiveError(typeDefinition, fld));
checkNamedUniqueness(errors, directive.getArguments(), Argument::getName, (argumentName, argument) -> new NonUniqueArgumentError(typeDefinition, fld, argumentName));
}));
}
Aggregations