本文整理汇总了Java中graphql.language.Field.getSelectionSet方法的典型用法代码示例。如果您正苦于以下问题:Java Field.getSelectionSet方法的具体用法?Java Field.getSelectionSet怎么用?Java Field.getSelectionSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphql.language.Field
的用法示例。
在下文中一共展示了Field.getSelectionSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildSchema
import graphql.language.Field; //导入方法依赖的package包/类
static Relation buildSchema(Field parentField) {
Relation parent = new Relation(parentField.getName());
for (Selection selection : parentField.getSelectionSet()
.getSelections()) {
if (selection instanceof Field) {
Field field = (Field) selection;
if (field.getSelectionSet() == null) {
if (!field.getName()
.equals("id")) {
parent.addChild(new Primitive(field.getName()));
}
} else {
parent.addChild(buildSchema(field));
}
} else if (selection instanceof InlineFragment) {
buildSchema(parent, (InlineFragment) selection);
} else if (selection instanceof FragmentSpread) {
}
}
return parent;
}
示例2: buildSelections
import graphql.language.Field; //导入方法依赖的package包/类
private void buildSelections(SelectionSet selectionSet, StringBuilder sb) {
for (Selection sel : selectionSet.getSelections()) {
if (sel instanceof Field) {
Field fieldSel = (Field) sel;
// Literal
if (fieldSel.getSelectionSet() == null) {
sb.append(fieldSel.getName()).append("\n");
} else { // Object
sb.append(fieldSel.getName()).append(" {\n");
buildSelections(fieldSel.getSelectionSet(), sb);
sb.append("}\n");
}
}
}
}