本文整理了Java中graphql.language.Field
类的一些代码示例,展示了Field
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field
类的具体详情如下:
包路径:graphql.language.Field
类名称:Field
暂无
代码示例来源:origin: graphql-java/graphql-java
String fieldNameA = fieldA.getName();
String fieldNameB = fieldB.getName();
if (!sameArguments(fieldA.getArguments(), fieldB.getArguments())) {
String reason = format("%s: they have differing arguments", responseName);
return new Conflict(responseName, reason, fieldA, fieldB);
SelectionSet selectionSet1 = fieldA.getSelectionSet();
SelectionSet selectionSet2 = fieldB.getSelectionSet();
if (selectionSet1 != null && selectionSet2 != null) {
Set<String> visitedFragmentSpreads = new LinkedHashSet<>();
代码示例来源:origin: graphql-java/graphql-java
private String getFieldEntryKey(Field field) {
if (field.getAlias() != null) {
return field.getAlias();
} else {
return field.getName();
}
}
代码示例来源:origin: graphql-java/graphql-java
@Override
public Field deepCopy() {
return new Field(name,
alias,
deepCopy(arguments),
deepCopy(directives),
deepCopy(selectionSet),
getSourceLocation(),
getComments(),
getIgnoredChars()
);
}
代码示例来源:origin: graphql-java/graphql-java
private Builder(Field existing) {
this.sourceLocation = existing.getSourceLocation();
this.comments = existing.getComments();
this.name = existing.getName();
this.alias = existing.getAlias();
this.arguments = existing.getArguments();
this.directives = existing.getDirectives();
this.selectionSet = existing.getSelectionSet();
this.ignoredChars = existing.getIgnoredChars();
}
代码示例来源:origin: yahoo/elide
public static boolean requestContainsPageInfo(Field field) {
return field.getSelectionSet().getSelections().stream()
.anyMatch(f -> f instanceof Field
&& ConnectionContainer.PAGE_INFO_KEYWORD.equals(((Field) f).getName()));
}
}
代码示例来源:origin: graphql-java/graphql-java
/**
* All merged fields have the same name.
*
* WARNING: This is not always the key in the execution result, because of possible aliases. See {@link #getResultKey()}
*
* @return the name of of the merged fields.
*/
public String getName() {
return fields.get(0).getName();
}
代码示例来源:origin: graphql-java/graphql-java
private NodePrinter<Field> field() {
final String argSep = compactMode ? "," : ", ";
final String aliasSuffix = compactMode ? ":" : ": ";
return (out, node) -> {
String alias = wrap("", node.getAlias(), aliasSuffix);
String name = node.getName();
String arguments = wrap("(", join(node.getArguments(), argSep), ")");
String directives = directives(node.getDirectives());
String selectionSet = node(node.getSelectionSet());
out.printf("%s", spaced(
alias + name + arguments,
directives,
selectionSet
));
};
}
代码示例来源:origin: com.introproventures/graphql-jpa-query-schema
String fieldName = recordsSelection.get().getName();
)).orElse(environment);
queryField = new Field(fieldName, field.getArguments(), recordsSelection.get().getSelectionSet());
.map(contentField -> getCountQuery(countQueryEnvironment, countQueryField).getSingleResult())
.orElseGet(() -> getCountQuery(environment, new Field("count")).getSingleResult());
代码示例来源:origin: graphql-java/graphql-java
QueryTraversalContext parentEnv = context.getVarFromParents(QueryTraversalContext.class);
GraphQLFieldDefinition fieldDefinition = Introspection.getFieldDef(schema, parentEnv.getRawType(), field.getName());
boolean isTypeNameIntrospectionField = fieldDefinition == Introspection.TypeNameMetaFieldDef;
GraphQLFieldsContainer fieldsContainer = !isTypeNameIntrospectionField ? (GraphQLFieldsContainer) unwrapAll(parentEnv.getOutputType()) : null;
GraphQLCodeRegistry codeRegistry = schema.getCodeRegistry();
Map<String, Object> argumentValues = valuesResolver.getArgumentValues(codeRegistry, fieldDefinition.getArguments(), field.getArguments(), variables);
QueryVisitorFieldEnvironment environment = new QueryVisitorFieldEnvironmentImpl(isTypeNameIntrospectionField,
field,
if (!conditionalNodes.shouldInclude(variables, field.getDirectives())) {
return TraversalControl.ABORT;
代码示例来源:origin: graphql-java/graphql-java
private void traverseFields(MergedField fieldList, GraphQLFieldsContainer parentFieldType, String fieldPrefix) {
FieldCollectorParameters parameters = FieldCollectorParameters.newParameters()
.schema(graphQLSchema)
.objectType(asObjectTypeOrNull(parentFieldType))
.fragments(fragmentsByName)
.variables(variables)
.build();
MergedSelectionSet collectedFields = fieldCollector.collectFields(parameters, fieldList);
for (Map.Entry<String, MergedField> entry : collectedFields.getSubFields().entrySet()) {
String fieldName = mkFieldName(fieldPrefix, entry.getKey());
MergedField collectedFieldList = entry.getValue();
selectionSetFields.put(fieldName, collectedFieldList);
Field field = collectedFieldList.getSingleField();
GraphQLFieldDefinition fieldDef = Introspection.getFieldDef(graphQLSchema, parentFieldType, field.getName());
GraphQLType unwrappedType = GraphQLTypeUtil.unwrapAll(fieldDef.getType());
Map<String, Object> argumentValues = valuesResolver.getArgumentValues(fieldDef.getArguments(), field.getArguments(), variables);
selectionSetFieldArgs.put(fieldName, argumentValues);
selectionSetFieldDefinitions.put(fieldName, fieldDef);
flattenedFields.add(fieldName);
if (unwrappedType instanceof GraphQLFieldsContainer) {
traverseFields(collectedFieldList, (GraphQLFieldsContainer) unwrappedType, fieldName);
}
}
}
代码示例来源:origin: semantic-integration/hypergraphql
private JsonNode getFieldJson(Field field, String parentId, String nodeId, String parentType) {
ObjectMapper mapper = new ObjectMapper();
ObjectNode query = mapper.createObjectNode();
query.put("name", field.getName());
query.put("alias", field.getAlias());
query.put("parentId", parentId);
query.put("nodeId", nodeId);
List<Argument> args = field.getArguments();
String contextLdKey = (field.getAlias()==null) ? field.getName() : field.getAlias();
String contextLdValue = getContextLdValue(contextLdKey);
this.ldContext.put(contextLdKey, contextLdValue);
if (args.isEmpty()) {
query.set("args", null);
} else {
query.set("args", getArgsJson(args));
}
FieldOfTypeConfig fieldConfig = hgqlSchema.getTypes().get(parentType).getField(field.getName());
String targetName = fieldConfig.getTargetName();
query.put("targetName", targetName);
query.set("fields", this.traverse(field, nodeId, parentType));
return query;
}
代码示例来源:origin: graphql-java/graphql-java
/**
* All merged fields share the same arguments.
*
* @return the list of arguments
*/
public List<Argument> getArguments() {
return getSingleField().getArguments();
}
代码示例来源:origin: graphql-java/graphql-java
@Override
public void checkField(Field field) {
GraphQLOutputType type = getValidationContext().getOutputType();
if (type == null) return;
if (isLeaf(type)) {
if (field.getSelectionSet() != null) {
String message = String.format("Sub selection not allowed on leaf type %s of field %s", type.getName(), field.getName());
addError(ValidationErrorType.SubSelectionNotAllowed, field.getSourceLocation(), message);
}
} else {
if (field.getSelectionSet() == null) {
String message = String.format("Sub selection required for type %s of field %s", type.getName(), field.getName());
addError(ValidationErrorType.SubSelectionRequired, field.getSourceLocation(), message);
}
}
}
}
代码示例来源:origin: graphql-java/graphql-java
@Override
public TraversalControl visitField(Field node, TraverserContext<Node> context) {
Field changedNode = node.transform(builder -> {
builder.arguments(sort(node.getArguments(), comparing(Argument::getName)));
builder.directives(sort(node.getDirectives(), comparing(Directive::getName)));
builder.selectionSet(sortSelectionSet(node.getSelectionSet()));
});
return changeNode(context, changedNode);
}
代码示例来源:origin: graphql-java/graphql-java
public MergedSelectionSet collectFields(FieldCollectorParameters parameters, MergedField mergedField) {
Map<String, MergedField> subFields = new LinkedHashMap<>();
List<String> visitedFragments = new ArrayList<>();
for (Field field : mergedField.getFields()) {
if (field.getSelectionSet() == null) {
continue;
}
this.collectFields(parameters, field.getSelectionSet(), visitedFragments, subFields);
}
return newMergedSelectionSet().subFields(subFields).build();
}
代码示例来源:origin: graphql-java/graphql-java
@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);
}
}
}
代码示例来源:origin: graphql-java/graphql-java
@Override
public void checkField(Field field) {
GraphQLFieldDefinition fieldDef = getValidationContext().getFieldDef();
if (fieldDef == null) return;
Map<String, Argument> argumentMap = argumentMap(field.getArguments());
for (GraphQLArgument graphQLArgument : fieldDef.getArguments()) {
Argument argument = argumentMap.get(graphQLArgument.getName());
if (argument == null
&& (isNonNull(graphQLArgument.getType()))
&& (graphQLArgument.getDefaultValue() == null)) {
String message = String.format("Missing field argument %s", graphQLArgument.getName());
addError(ValidationErrorType.MissingFieldArgument, field.getSourceLocation(), message);
}
}
}
代码示例来源:origin: graphql-java/graphql-java
@Override
public void checkField(Field field) {
checkDirectivesUniqueness(field, field.getDirectives());
}
代码示例来源:origin: graphql-java/graphql-java
public Field build() {
Field field = new Field(name, alias, arguments, directives, selectionSet, sourceLocation, comments, ignoredChars);
return field;
}
}
代码示例来源:origin: com.yahoo.elide/elide-graphql
public static boolean requestContainsPageInfo(Field field) {
return field.getSelectionSet().getSelections().stream()
.anyMatch(f -> f instanceof Field
&& ConnectionContainer.PAGE_INFO_KEYWORD.equals(((Field) f).getName()));
}
}
内容来源于网络,如有侵权,请联系作者删除!