/** * Returns the key of this MergedField for the overall result. * This is either an alias or the field name. * * @return the key for this MergedField. */ public String getResultKey() { Field singleField = getSingleField(); if (singleField.getAlias() != null) { return singleField.getAlias(); } return singleField.getName(); }
private void collectFieldsForField(Map<String, List<FieldAndType>> fieldMap, GraphQLType parentType, Field field) { String responseName = field.getAlias() != null ? field.getAlias() : field.getName(); if (!fieldMap.containsKey(responseName)) { fieldMap.put(responseName, new ArrayList<>()); } GraphQLOutputType fieldType = null; GraphQLUnmodifiedType unwrappedParent = unwrapAll(parentType); if (unwrappedParent instanceof GraphQLFieldsContainer) { GraphQLFieldsContainer fieldsContainer = (GraphQLFieldsContainer) unwrappedParent; GraphQLFieldDefinition fieldDefinition = getVisibleFieldDefinition(fieldsContainer, field); fieldType = fieldDefinition != null ? fieldDefinition.getType() : null; } fieldMap.get(responseName).add(new FieldAndType(field, fieldType, parentType)); }
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(); }
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 )); }; }
/** * Returns the key of this MergedField for the overall result. * This is either an alias or the field name. * * @return the key for this MergedField. */ public String getResultKey() { Field singleField = getSingleField(); if (singleField.getAlias() != null) { return singleField.getAlias(); } return singleField.getName(); }
private void collectFieldsForField(Map<String, List<FieldAndType>> fieldMap, GraphQLType parentType, Field field) { String responseName = field.getAlias() != null ? field.getAlias() : field.getName(); if (!fieldMap.containsKey(responseName)) { fieldMap.put(responseName, new ArrayList<>()); } GraphQLOutputType fieldType = null; GraphQLUnmodifiedType unwrappedParent = unwrapAll(parentType); if (unwrappedParent instanceof GraphQLFieldsContainer) { GraphQLFieldsContainer fieldsContainer = (GraphQLFieldsContainer) unwrappedParent; GraphQLFieldDefinition fieldDefinition = getVisibleFieldDefinition(fieldsContainer, field); fieldType = fieldDefinition != null ? fieldDefinition.getType() : null; } fieldMap.get(responseName).add(new FieldAndType(field, fieldType, parentType)); }
public DataFetcher<List<RDFNode>> instancesOfTypeFetcher() { return environment -> { Field field = (Field) environment.getFields().toArray()[0]; String predicate = (field.getAlias() == null) ? field.getName() : field.getAlias(); ModelContainer client = environment.getContext(); return client.getValuesOfObjectProperty( HGQLVocabulary.HGQL_QUERY_URI, HGQLVocabulary.HGQL_QUERY_NAMESPACE + predicate ); }; }
public DataFetcher<List<RDFNode>> instancesOfTypeFetcher() { return environment -> { Field field = (Field) environment.getFields().toArray()[0]; String predicate = (field.getAlias() == null) ? field.getName() : field.getAlias(); ModelContainer client = environment.getContext(); return client.getValuesOfObjectProperty( HGQLVocabulary.HGQL_QUERY_URI, HGQLVocabulary.HGQL_QUERY_NAMESPACE + predicate ); }; }
public ResolvedField(Field field, GraphQLFieldDefinition fieldDefinition, Map<String, Object> arguments, Map<String, ResolvedField> children) { this.name = field.getAlias() != null ? field.getAlias() : field.getName(); this.field = field; this.fieldDefinition = fieldDefinition; this.fieldType = (GraphQLOutputType) GraphQLUtils.unwrap(fieldDefinition.getType()); this.arguments = arguments; this.children = children; this.resolver = findResolver(fieldDefinition, arguments); }
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; }
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; }
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(); }
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 )); }; }