use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class QueryTraversal method visitImpl.
private void visitImpl(FieldVisitor visitFieldCallback, SelectionSet selectionSet, GraphQLCompositeType type, boolean preOrder) {
Map<Class<?>, Object> rootVars = new LinkedHashMap<>();
rootVars.put(QueryTraversalContext.class, new QueryTraversalContext(type, null));
FieldVisitor noOp = notUsed -> {
};
FieldVisitor preOrderCallback = preOrder ? visitFieldCallback : noOp;
FieldVisitor postOrderCallback = !preOrder ? visitFieldCallback : noOp;
NodeTraverser nodeTraverser = new NodeTraverser(rootVars, this::childrenOf);
nodeTraverser.depthFirst(new NodeVisitorImpl(preOrderCallback, postOrderCallback), selectionSet.getSelections());
}
use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class FragmentsOnCompositeType method checkFragmentDefinition.
@Override
public void checkFragmentDefinition(FragmentDefinition fragmentDefinition) {
GraphQLType type = getValidationContext().getSchema().getType(fragmentDefinition.getTypeCondition().getName());
if (type == null)
return;
if (!(type instanceof GraphQLCompositeType)) {
String message = "Fragment type condition is invalid, must be on Object/Interface/Union";
addError(ValidationErrorType.InlineFragmentTypeConditionInvalid, fragmentDefinition.getSourceLocation(), message);
}
}
use of graphql.schema.GraphQLCompositeType in project graphql-java by graphql-java.
the class FragmentsOnCompositeType method checkInlineFragment.
@Override
public void checkInlineFragment(InlineFragment inlineFragment) {
if (inlineFragment.getTypeCondition() == null) {
return;
}
GraphQLType type = getValidationContext().getSchema().getType(inlineFragment.getTypeCondition().getName());
if (type == null)
return;
if (!(type instanceof GraphQLCompositeType)) {
String message = "Inline fragment type condition is invalid, must be on Object/Interface/Union";
addError(ValidationErrorType.InlineFragmentTypeConditionInvalid, inlineFragment.getSourceLocation(), message);
}
}
Aggregations