If you are interested in more in-depth overview of how selection works, check out selection documentation.
Selection.Query
since we are going to select a field in the root Query
. This is a generic type that can be used to query any type of data. In this case, we’re querying a String
value, that’s why we particularize the generic to return a string.QueryBuilder
as the only argument which lets us select fields available in that type - in our case world
field in the Query
type.hello
so we can reuse it in many places.Notice that instead of always relying onbuilder
argument, we use$0
to refer to theQueryBuilder
instance.
String
value to an URL
and fail if it’s not a valid URL,It’s important that you always make selection before any logical operation on it. Otherwise, it could happen that some fields are missing from the selection.
OptionalArgument
enumerator.
NOTE: Every nullable argument is by default absent so you don’t have to write boilerplate code.Because writing
OptionalArgument
is cumbersome, SwiftGraphQL provides a convenience operator ~
that transforms scalar values into present optional arguments.