-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add NadelResultPath value type so it doesn't feed into List params
- Loading branch information
Showing
7 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package graphql.nadel.result | ||
|
||
@JvmInline | ||
internal value class NadelResultPath( | ||
val value: List<NadelResultPathSegment>, | ||
) { | ||
operator fun plus(key: String): NadelResultPath { | ||
return NadelResultPath(value + NadelResultPathSegment.Object(key)) | ||
} | ||
|
||
operator fun plus(key: Int): NadelResultPath { | ||
return NadelResultPath(value + NadelResultPathSegment.Array(key)) | ||
} | ||
|
||
fun clone(): NadelResultPath { | ||
return NadelResultPath(value = value.toList()) | ||
} | ||
|
||
fun toRawPath(): List<Any> { | ||
return value.map { | ||
when (it) { | ||
is NadelResultPathSegment.Array -> it.index | ||
is NadelResultPathSegment.Object -> it.key | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
val empty = NadelResultPath(value = emptyList()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters