Skip to content

Instantly share code, notes, and snippets.

@ngw
Last active August 23, 2018 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngw/6671b2e0e17c452c6c8df8fde8141ebf to your computer and use it in GitHub Desktop.
Save ngw/6671b2e0e17c452c6c8df8fde8141ebf to your computer and use it in GitHub Desktop.
userByEmail : UserByEmailRequiredArguments -> SelectionSet decodesTo Schema.Object.User -> Field (Maybe decodesTo) RootQuery
userByEmail requiredArgs object =
Object.selectionField "userByEmail" [ Argument.required "email" requiredArgs.email Encode.string ] object (identity >> Decode.nullable)
type alias EmailQueryResponse =
{ email : Maybe Email }
type alias Email =
{ email: String }
query : SelectionSet EmailQueryResponse RootQuery
query =
let
q = Query.selection EmailQueryResponse |> with (Query.userByEmail { email = "ngw@test.org" } user)
in
Debug.log "Q" q
user : SelectionSet Email Schema.Object.User
user =
Schema.Object.User.selection Email
|> with Schema.Object.User.email
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment