use of graphql.schema.GraphQLType in project graphql-java by graphql-java.
the class FieldCollector method doesFragmentConditionMatch.
private boolean doesFragmentConditionMatch(FieldCollectorParameters parameters, InlineFragment inlineFragment) {
if (inlineFragment.getTypeCondition() == null) {
return true;
}
GraphQLType conditionType;
conditionType = getTypeFromAST(parameters.getGraphQLSchema(), inlineFragment.getTypeCondition());
return checkTypeCondition(parameters, conditionType);
}
use of graphql.schema.GraphQLType in project graphql-java by graphql-java.
the class FieldCollector method doesFragmentConditionMatch.
private boolean doesFragmentConditionMatch(FieldCollectorParameters parameters, FragmentDefinition fragmentDefinition) {
GraphQLType conditionType;
conditionType = getTypeFromAST(parameters.getGraphQLSchema(), fragmentDefinition.getTypeCondition());
return checkTypeCondition(parameters, conditionType);
}
use of graphql.schema.GraphQLType in project graphql-java by graphql-java.
the class SchemaPrinter method printComments.
private void printComments(PrintWriter out, Object graphQLType, String prefix) {
AstDescriptionAndComments descriptionAndComments = getDescriptionAndComments(graphQLType);
if (descriptionAndComments == null) {
return;
}
Description astDescription = descriptionAndComments.descriptionAst;
if (astDescription != null) {
String quoteStr = "\"";
if (astDescription.isMultiLine()) {
quoteStr = "\"\"\"";
}
out.write(prefix);
out.write(quoteStr);
out.write(astDescription.getContent());
out.write(quoteStr);
out.write("\n");
return;
}
if (descriptionAndComments.comments != null) {
descriptionAndComments.comments.forEach(cmt -> {
out.write(prefix);
out.write("#");
out.write(cmt.getContent());
out.write("\n");
});
} else {
String runtimeDescription = descriptionAndComments.runtimeDescription;
if (!isNullOrEmpty(runtimeDescription)) {
Stream<String> stream = Arrays.stream(runtimeDescription.split("\n"));
stream.map(s -> prefix + "#" + s + "\n").forEach(out::write);
}
}
}
use of graphql.schema.GraphQLType in project graphql-java by graphql-java.
the class VariableTypesMatchRule method checkVariable.
@Override
public void checkVariable(VariableReference variableReference) {
VariableDefinition variableDefinition = variableDefinitionMap.get(variableReference.getName());
if (variableDefinition == null) {
return;
}
GraphQLType variableType = TypeFromAST.getTypeFromAST(getValidationContext().getSchema(), variableDefinition.getType());
if (variableType == null) {
return;
}
GraphQLInputType expectedType = getValidationContext().getInputType();
if (expectedType == null) {
// we must have a unknown variable say to not have a known type
return;
}
if (!variablesTypesMatcher.doesVariableTypesMatch(variableType, variableDefinition.getDefaultValue(), expectedType)) {
GraphQLType effectiveType = variablesTypesMatcher.effectiveType(variableType, variableDefinition.getDefaultValue());
String message = String.format("Variable type '%s' doesn't match expected type '%s'", GraphQLTypeUtil.getUnwrappedTypeName(effectiveType), GraphQLTypeUtil.getUnwrappedTypeName(expectedType));
addError(ValidationErrorType.VariableTypeMismatch, variableReference.getSourceLocation(), message);
}
}
use of graphql.schema.GraphQLType in project graphql-java by graphql-java.
the class TraversalContext method enterImpl.
private void enterImpl(FragmentDefinition fragmentDefinition) {
enterName(fragmentDefinition.getName());
GraphQLType type = schema.getType(fragmentDefinition.getTypeCondition().getName());
addOutputType((GraphQLOutputType) type);
}
Aggregations