-
-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reads `CI` environment variable (same as sbt) to determine if we're running in CI. This variable determines which behaviour the tests have - If we're running in CI it checks that the contents of all the snapshot files are up to date - Otherwise, it'll the files with new contents. The point is that a given change will showcase the effective results right in the PR, and otherwise be convenient to work with
- Loading branch information
1 parent
a0b0287
commit f1e0bf9
Showing
11 changed files
with
1,426 additions
and
1,131 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
tools/src/test/resources/snapshots/generic view for capital fields.scala
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,27 @@ | ||
import caliban.client.FieldBuilder._ | ||
import caliban.client._ | ||
|
||
object Client { | ||
|
||
type TypeWithCapitalFields | ||
object TypeWithCapitalFields { | ||
|
||
final case class TypeWithCapitalFieldsView( | ||
Name: scala.Option[String], | ||
Value: scala.Option[String] | ||
) | ||
|
||
type ViewSelection = | ||
SelectionBuilder[TypeWithCapitalFields, TypeWithCapitalFieldsView] | ||
|
||
def view: ViewSelection = (Name ~ Value).map { case (name$, value$) => | ||
TypeWithCapitalFieldsView(name$, value$) | ||
} | ||
|
||
def Name: SelectionBuilder[TypeWithCapitalFields, scala.Option[String]] = | ||
_root_.caliban.client.SelectionBuilder.Field("Name", OptionOf(Scalar())) | ||
def Value: SelectionBuilder[TypeWithCapitalFields, scala.Option[String]] = | ||
_root_.caliban.client.SelectionBuilder.Field("Value", OptionOf(Scalar())) | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
tools/src/test/resources/snapshots/generic view for scala keywords.scala
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,47 @@ | ||
import caliban.client.FieldBuilder._ | ||
import caliban.client._ | ||
|
||
object Client { | ||
|
||
type `package` | ||
object `package` { | ||
|
||
final case class packageView(name: scala.Option[String]) | ||
|
||
type ViewSelection = SelectionBuilder[`package`, packageView] | ||
|
||
def view: ViewSelection = name.map(name => packageView(name)) | ||
|
||
def name: SelectionBuilder[`package`, scala.Option[String]] = | ||
_root_.caliban.client.SelectionBuilder.Field("name", OptionOf(Scalar())) | ||
} | ||
|
||
type `match` | ||
object `match` { | ||
|
||
final case class matchView[PackageSelection]( | ||
`package`: scala.Option[PackageSelection], | ||
version: scala.Option[String] | ||
) | ||
|
||
type ViewSelection[PackageSelection] = | ||
SelectionBuilder[`match`, matchView[PackageSelection]] | ||
|
||
def view[PackageSelection]( | ||
packageSelection: SelectionBuilder[`package`, PackageSelection] | ||
): ViewSelection[PackageSelection] = | ||
(`package`(packageSelection) ~ version).map { case (package$, version) => | ||
matchView(package$, version) | ||
} | ||
|
||
def `package`[A]( | ||
innerSelection: SelectionBuilder[`package`, A] | ||
): SelectionBuilder[`match`, scala.Option[A]] = | ||
_root_.caliban.client.SelectionBuilder | ||
.Field("package", OptionOf(Obj(innerSelection))) | ||
def version: SelectionBuilder[`match`, scala.Option[String]] = | ||
_root_.caliban.client.SelectionBuilder | ||
.Field("version", OptionOf(Scalar())) | ||
} | ||
|
||
} |
132 changes: 132 additions & 0 deletions
132
.../test/resources/snapshots/generic view for scala.Option[List[scala.Option[A]] types.scala
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,132 @@ | ||
import caliban.client.FieldBuilder._ | ||
import caliban.client._ | ||
|
||
object Client { | ||
|
||
type ProjectMember | ||
object ProjectMember { | ||
|
||
final case class ProjectMemberView( | ||
id: scala.Option[Int], | ||
name: scala.Option[String] | ||
) | ||
|
||
type ViewSelection2 = SelectionBuilder[ProjectMember, ProjectMemberView] | ||
|
||
def view: ViewSelection = (id ~ name).map { case (id, name) => | ||
ProjectMemberView(id, name) | ||
} | ||
|
||
def id: SelectionBuilder[ProjectMember, scala.Option[Int]] = | ||
_root_.caliban.client.SelectionBuilder.Field("id", OptionOf(Scalar())) | ||
def name: SelectionBuilder[ProjectMember, scala.Option[String]] = | ||
_root_.caliban.client.SelectionBuilder.Field("name", OptionOf(Scalar())) | ||
} | ||
|
||
type ProjectMemberEdge | ||
object ProjectMemberEdge { | ||
|
||
final case class ProjectMemberEdgeView[NodeSelection]( | ||
cursor: String, | ||
node: scala.Option[NodeSelection] | ||
) | ||
|
||
type ViewSelection[NodeSelection] = | ||
SelectionBuilder[ProjectMemberEdge, ProjectMemberEdgeView[NodeSelection]] | ||
|
||
def view[NodeSelection]( | ||
nodeSelection: SelectionBuilder[ProjectMember, NodeSelection] | ||
): ViewSelection[NodeSelection] = (cursor ~ node(nodeSelection)).map { | ||
case (cursor, node) => ProjectMemberEdgeView(cursor, node) | ||
} | ||
|
||
def cursor: SelectionBuilder[ProjectMemberEdge, String] = | ||
_root_.caliban.client.SelectionBuilder.Field("cursor", Scalar()) | ||
def node[A]( | ||
innerSelection: SelectionBuilder[ProjectMember, A] | ||
): SelectionBuilder[ProjectMemberEdge, scala.Option[A]] = | ||
_root_.caliban.client.SelectionBuilder | ||
.Field("node", OptionOf(Obj(innerSelection))) | ||
} | ||
|
||
type PageInfo | ||
object PageInfo { | ||
|
||
final case class PageInfoView( | ||
endCursor: scala.Option[String], | ||
hasNextPage: Boolean, | ||
hasPreviousPage: Boolean, | ||
startCursor: scala.Option[String] | ||
) | ||
|
||
type ViewSelection = SelectionBuilder[PageInfo, PageInfoView] | ||
|
||
def view: ViewSelection = | ||
(endCursor ~ hasNextPage ~ hasPreviousPage ~ startCursor).map { | ||
case (endCursor, hasNextPage, hasPreviousPage, startCursor) => | ||
PageInfoView(endCursor, hasNextPage, hasPreviousPage, startCursor) | ||
} | ||
|
||
def endCursor: SelectionBuilder[PageInfo, scala.Option[String]] = | ||
_root_.caliban.client.SelectionBuilder | ||
.Field("endCursor", OptionOf(Scalar())) | ||
def hasNextPage: SelectionBuilder[PageInfo, Boolean] = | ||
_root_.caliban.client.SelectionBuilder.Field("hasNextPage", Scalar()) | ||
def hasPreviousPage: SelectionBuilder[PageInfo, Boolean] = | ||
_root_.caliban.client.SelectionBuilder.Field("hasPreviousPage", Scalar()) | ||
def startCursor: SelectionBuilder[PageInfo, scala.Option[String]] = | ||
_root_.caliban.client.SelectionBuilder | ||
.Field("startCursor", OptionOf(Scalar())) | ||
} | ||
|
||
type ProjectMemberConnection | ||
object ProjectMemberConnection { | ||
|
||
final case class ProjectMemberConnectionView[ | ||
EdgesSelection, | ||
NodesSelection, | ||
PageInfoSelection | ||
]( | ||
edges: scala.Option[List[scala.Option[EdgesSelection]]], | ||
nodes: scala.Option[List[scala.Option[NodesSelection]]], | ||
pageInfo: PageInfoSelection | ||
) | ||
|
||
type ViewSelection[EdgesSelection, NodesSelection, PageInfoSelection] = | ||
SelectionBuilder[ProjectMemberConnection, ProjectMemberConnectionView[ | ||
EdgesSelection, | ||
NodesSelection, | ||
PageInfoSelection | ||
]] | ||
|
||
def view[EdgesSelection, NodesSelection, PageInfoSelection]( | ||
edgesSelection: SelectionBuilder[ProjectMemberEdge, EdgesSelection], | ||
nodesSelection: SelectionBuilder[ProjectMember, NodesSelection], | ||
pageInfoSelection: SelectionBuilder[PageInfo, PageInfoSelection] | ||
): ViewSelection[EdgesSelection, NodesSelection, PageInfoSelection] = | ||
(edges(edgesSelection) ~ nodes(nodesSelection) ~ pageInfo( | ||
pageInfoSelection | ||
)).map { case (edges, nodes, pageInfo) => | ||
ProjectMemberConnectionView(edges, nodes, pageInfo) | ||
} | ||
|
||
def edges[A]( | ||
innerSelection: SelectionBuilder[ProjectMemberEdge, A] | ||
): SelectionBuilder[ProjectMemberConnection, scala.Option[List[ | ||
scala.Option[A] | ||
]]] = _root_.caliban.client.SelectionBuilder | ||
.Field("edges", OptionOf(ListOf(OptionOf(Obj(innerSelection))))) | ||
def nodes[A]( | ||
innerSelection: SelectionBuilder[ProjectMember, A] | ||
): SelectionBuilder[ProjectMemberConnection, scala.Option[List[ | ||
scala.Option[A] | ||
]]] = _root_.caliban.client.SelectionBuilder | ||
.Field("nodes", OptionOf(ListOf(OptionOf(Obj(innerSelection))))) | ||
def pageInfo[A]( | ||
innerSelection: SelectionBuilder[PageInfo, A] | ||
): SelectionBuilder[ProjectMemberConnection, A] = | ||
_root_.caliban.client.SelectionBuilder | ||
.Field("pageInfo", Obj(innerSelection)) | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
tools/src/test/resources/snapshots/nested object type.scala
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,82 @@ | ||
import caliban.client.FieldBuilder._ | ||
import caliban.client._ | ||
|
||
object Client { | ||
|
||
type Q | ||
object Q { | ||
|
||
final case class QView[UsersSelection](users: List[UsersSelection]) | ||
|
||
type ViewSelection[UsersSelection] = | ||
SelectionBuilder[Q, QView[UsersSelection]] | ||
|
||
def view[UsersSelection]( | ||
usersSelection: SelectionBuilder[User, UsersSelection] | ||
): ViewSelection[UsersSelection] = | ||
users(usersSelection).map(users => QView(users)) | ||
|
||
def users[A]( | ||
innerSelection: SelectionBuilder[User, A] | ||
): SelectionBuilder[Q, List[A]] = _root_.caliban.client.SelectionBuilder | ||
.Field("users", ListOf(Obj(innerSelection))) | ||
} | ||
|
||
type Character | ||
object Character { | ||
|
||
final case class CharacterView( | ||
name: String, | ||
age: Int, | ||
nicknames: List[String] | ||
) | ||
|
||
type ViewSelection = SelectionBuilder[Character, CharacterView] | ||
|
||
def view(nicknamesArg: scala.Option[Int] = None): ViewSelection = | ||
(name ~ age ~ nicknames(nicknamesArg)).map { | ||
case (name, age, nicknames) => CharacterView(name, age, nicknames) | ||
} | ||
|
||
def name: SelectionBuilder[Character, String] = | ||
_root_.caliban.client.SelectionBuilder.Field("name", Scalar()) | ||
def age: SelectionBuilder[Character, Int] = | ||
_root_.caliban.client.SelectionBuilder.Field("age", Scalar()) | ||
def nicknames(arg: scala.Option[Int] = None)(implicit | ||
encoder0: ArgEncoder[scala.Option[Int]] | ||
): SelectionBuilder[Character, List[String]] = | ||
_root_.caliban.client.SelectionBuilder.Field( | ||
"nicknames", | ||
ListOf(Scalar()), | ||
arguments = List(Argument("arg", arg, "Int")(encoder0)) | ||
) | ||
} | ||
|
||
type User | ||
object User { | ||
|
||
final case class UserView[CharactersSelection]( | ||
characters: List[CharactersSelection] | ||
) | ||
|
||
type ViewSelection[CharactersSelection] = | ||
SelectionBuilder[User, UserView[CharactersSelection]] | ||
|
||
def view[CharactersSelection](charactersName: String)( | ||
charactersSelection: SelectionBuilder[Character, CharactersSelection] | ||
): ViewSelection[CharactersSelection] = | ||
characters(charactersName)(charactersSelection).map(characters => | ||
UserView(characters) | ||
) | ||
|
||
def characters[A](name: String)( | ||
innerSelection: SelectionBuilder[Character, A] | ||
)(implicit encoder0: ArgEncoder[String]): SelectionBuilder[User, List[A]] = | ||
_root_.caliban.client.SelectionBuilder.Field( | ||
"characters", | ||
ListOf(Obj(innerSelection)), | ||
arguments = List(Argument("name", name, "String!")(encoder0)) | ||
) | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
tools/src/test/resources/snapshots/recursive object type.scala
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,41 @@ | ||
import caliban.client.FieldBuilder._ | ||
import caliban.client._ | ||
|
||
object Client { | ||
|
||
type Character | ||
object Character { | ||
|
||
final case class CharacterView[FriendsSelection]( | ||
name: String, | ||
age: Int, | ||
friends: List[FriendsSelection] | ||
) | ||
|
||
type ViewSelection[FriendsSelection] = | ||
SelectionBuilder[Character, CharacterView[FriendsSelection]] | ||
|
||
def view[FriendsSelection](friendsFilter: scala.Option[String] = None)( | ||
friendsSelection: SelectionBuilder[Character, FriendsSelection] | ||
): ViewSelection[FriendsSelection] = | ||
(name ~ age ~ friends(friendsFilter)(friendsSelection)).map { | ||
case (name, age, friends) => CharacterView(name, age, friends) | ||
} | ||
|
||
def name: SelectionBuilder[Character, String] = | ||
_root_.caliban.client.SelectionBuilder.Field("name", Scalar()) | ||
def age: SelectionBuilder[Character, Int] = | ||
_root_.caliban.client.SelectionBuilder.Field("age", Scalar()) | ||
def friends[A]( | ||
filter: scala.Option[String] = None | ||
)(innerSelection: SelectionBuilder[Character, A])(implicit | ||
encoder0: ArgEncoder[scala.Option[String]] | ||
): SelectionBuilder[Character, List[A]] = | ||
_root_.caliban.client.SelectionBuilder.Field( | ||
"friends", | ||
ListOf(Obj(innerSelection)), | ||
arguments = List(Argument("filter", filter, "String")(encoder0)) | ||
) | ||
} | ||
|
||
} |
Oops, something went wrong.