use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class PossibleFragmentSpreads method checkFragmentSpread.
@Override
public void checkFragmentSpread(FragmentSpread fragmentSpread) {
FragmentDefinition fragment = getValidationContext().getFragment(fragmentSpread.getName());
if (fragment == null)
return;
GraphQLType typeCondition = TypeFromAST.getTypeFromAST(getValidationContext().getSchema(), fragment.getTypeCondition());
GraphQLCompositeType parentType = getValidationContext().getParentType();
if (typeCondition == null || parentType == null)
return;
if (!doTypesOverlap(typeCondition, parentType)) {
String message = String.format("Fragment %s cannot be spread here as objects of " + "type %s can never be of type %s", fragmentSpread.getName(), parentType, typeCondition);
addError(ValidationErrorType.InvalidFragmentType, fragmentSpread.getSourceLocation(), message);
}
}
use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class PossibleFragmentSpreads method checkInlineFragment.
@Override
public void checkInlineFragment(InlineFragment inlineFragment) {
GraphQLOutputType fragType = getValidationContext().getOutputType();
GraphQLCompositeType parentType = getValidationContext().getParentType();
if (fragType == null || parentType == null)
return;
if (!doTypesOverlap(fragType, parentType)) {
String message = String.format("Fragment cannot be spread here as objects of " + "type %s can never be of type %s", parentType, fragType);
addError(ValidationErrorType.InvalidFragmentType, inlineFragment.getSourceLocation(), message);
}
}
use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class TraversalContext method enterImpl.
private void enterImpl(Field field) {
enterName(field.getName());
GraphQLCompositeType parentType = getParentType();
GraphQLFieldDefinition fieldDefinition = null;
if (parentType != null) {
fieldDefinition = getFieldDef(schema, parentType, field);
}
addFieldDef(fieldDefinition);
addOutputType(fieldDefinition != null ? fieldDefinition.getType() : null);
}
use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class TraversalContext method enterImpl.
private void enterImpl(SelectionSet selectionSet) {
GraphQLUnmodifiedType rawType = new SchemaUtil().getUnmodifiedType(getOutputType());
GraphQLCompositeType parentType = null;
if (rawType instanceof GraphQLCompositeType) {
parentType = (GraphQLCompositeType) rawType;
}
addParentType(parentType);
}
use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class FieldsOnCorrectType method checkField.
@Override
public void checkField(Field field) {
GraphQLCompositeType parentType = getValidationContext().getParentType();
// this means the parent type is not a CompositeType, which is an error handled elsewhere
if (parentType == null)
return;
GraphQLFieldDefinition fieldDef = getValidationContext().getFieldDef();
if (fieldDef == null) {
String message = String.format("Field '%s' in type '%s' is undefined", field.getName(), parentType.getName());
addError(ValidationErrorType.FieldUndefined, field.getSourceLocation(), message);
}
}
Aggregations