Package graphql.execution
Class ResultPath
java.lang.Object
graphql.execution.ResultPath
As a graphql query is executed, each field forms a hierarchical path from parent field to child field and this
class represents that path as a series of segments.
-
Method Summary
Modifier and TypeMethodDescriptionappend
(ResultPath path) Appends the provided path to the current oneDrops the last segment off the pathboolean
static ResultPath
This will create an execution path from the list of objectsint
getLevel()
int
int
hashCode()
boolean
boolean
boolean
static ResultPath
Parses an execution path from the provided path string in the format /segment1/segment2[index]/segmentNreplaceSegment
(int segment) Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment(9) equals "/a/b[9]"replaceSegment
(String segment) Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment("x") equals "/a/b/x"static ResultPath
rootPath()
All paths start from heresegment
(int segment) Takes the current path and adds a new segment to it, returning a new pathTakes the current path and adds a new segment to it, returning a new pathsibling
(int siblingField) toList()
toString()
-
Method Details
-
rootPath
All paths start from here- Returns:
- the root path
-
getLevel
public int getLevel() -
getPathWithoutListEnd
-
isListSegment
public boolean isListSegment()- Returns:
- true if the end of the path has a list style segment eg 'a/b[2]'
-
isNamedSegment
public boolean isNamedSegment()- Returns:
- true if the end of the path has a named style segment eg 'a/b[2]/c'
-
getSegmentName
-
getSegmentIndex
public int getSegmentIndex() -
getSegmentValue
-
getParent
-
parse
Parses an execution path from the provided path string in the format /segment1/segment2[index]/segmentN- Parameters:
pathString
- the path string- Returns:
- a parsed execution path
-
fromList
This will create an execution path from the list of objects- Parameters:
objects
- the path objects- Returns:
- a new execution path
-
segment
Takes the current path and adds a new segment to it, returning a new path- Parameters:
segment
- the string path segment to add- Returns:
- a new path containing that segment
-
segment
Takes the current path and adds a new segment to it, returning a new path- Parameters:
segment
- the int path segment to add- Returns:
- a new path containing that segment
-
dropSegment
Drops the last segment off the path- Returns:
- a new path with the last segment dropped off
-
replaceSegment
Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment(9) equals "/a/b[9]"- Parameters:
segment
- the integer segment to use- Returns:
- a new path with the last segment replaced
-
replaceSegment
Replaces the last segment on the path eg ResultPath.parse("/a/b[1]").replaceSegment("x") equals "/a/b/x"- Parameters:
segment
- the string segment to use- Returns:
- a new path with the last segment replaced
-
isRootPath
public boolean isRootPath()- Returns:
- true if the path is the
rootPath()
-
append
Appends the provided path to the current one- Parameters:
path
- the path to append- Returns:
- a new path
-
sibling
-
sibling
-
toList
- Returns:
- converts the path into a list of segments
-
getKeysOnly
- Returns:
- this path as a list of result keys, without any indices
-
toString
-
segmentToString
-
equals
-
hashCode
public int hashCode()
-