Module

GraphQLClient.Implementation

#Scope__RootQuery

#Scope__RootMutation

#Scope__RootSubscription

#SelectionSet

data SelectionSet parentTypeLock a

Constructors

Instances

#map2

map2 :: forall parentTypeLock a b c. (a -> b -> c) -> SelectionSet parentTypeLock a -> SelectionSet parentTypeLock b -> SelectionSet parentTypeLock c

#foldl

foldl :: forall a b parentTypeLock. (b -> a -> b) -> b -> Array (SelectionSet parentTypeLock a) -> SelectionSet parentTypeLock b

#FragmentSelectionSet

#fieldNameWithHash

fieldNameWithHash :: Maybe Cache -> String -> String

Q: why we need fieldNameWithHash and fieldNameWithoutHash

TLDR A:

  • fieldNameWithHash is used by default everywhere (in client for example),
  • fieldNameWithoutHash is used only for internal use in GraphQLClientGenerator.IntrospectionSchema module (to make generated query equal to the one that is generated by require("graphql").introspectionFromSchema(graphQLSchema))

Long A: When the field is requested with some argument - the generated field name should be unique to prevent errors if the same field is requested with different arguments in some other place

For example:

given schema

schema {
  query: RootQueryType
}

type RootQueryType {
  xxx: Int!
  yyy(yyyArg: Boolean!): String!
}

and code

xxx :: SelectionSet Scope__RootQuery Int
xxx = selectionForField "xxx" [] graphqlDefaultResponseScalarDecoder

yyy :: { yyyArg :: Boolean } -> SelectionSet Scope__RootQuery String
yyy input = selectionForField "yyy" (toGraphQLArguments input) graphqlDefaultResponseScalarDecoder
-- which is equal to
-- yyy input = selectionForField "yyy" [RequiredArgument "yyyArg" (ArgumentValueBoolean input.yyyArg)] graphqlDefaultResponseScalarDecoder

myQuery :: SelectionSet Scope__RootQuery { xxx :: Boolean, yyy1 :: String, yyy2 :: String }
myQuery =
  { xxx: _, yyy1: _, yyy2: _ }
  <$> xxx
  <*> yyy { yyyArg: true }
  <*> yyy { yyyArg: false }

should generate

query {
  xxx
  yyyUNIQ_HASH_FROM_ARGS: yyy(yyyArg: true)
  yyyUNIQ_HASH_FROM_ARGS2: yyy(yyyArg: false)
}

The hash was generated because selectionForField arguments array WAS NOT EMPTY!

#fieldNameWithoutHash

#selectionForFieldImplementation

selectionForFieldImplementation :: forall parentTypeLock a. (Maybe Cache -> String -> String) -> String -> Array Argument -> (Json -> Either JsonDecodeError a) -> SelectionSet parentTypeLock a

#selectionForField

selectionForField :: forall parentTypeLock a. String -> Array Argument -> (Json -> Either JsonDecodeError a) -> SelectionSet parentTypeLock a

#selectionForCompositeFieldImplementation

selectionForCompositeFieldImplementation :: forall objectTypeLock lockedTo a b. (Maybe Cache -> String -> String) -> String -> Array Argument -> ((Json -> Either JsonDecodeError a) -> Json -> Either JsonDecodeError b) -> SelectionSet objectTypeLock a -> SelectionSet lockedTo b

#selectionForCompositeField

selectionForCompositeField :: forall objectTypeLock lockedTo a b. String -> Array Argument -> ((Json -> Either JsonDecodeError a) -> Json -> Either JsonDecodeError b) -> SelectionSet objectTypeLock a -> SelectionSet lockedTo b

#buildFragment

buildFragment :: forall decodesTo selectionLock fragmentLock. String -> SelectionSet selectionLock decodesTo -> FragmentSelectionSet fragmentLock decodesTo

#exhaustiveFragmentSelection

exhaustiveFragmentSelection :: forall typeLock decodesTo. Array (FragmentSelectionSet typeLock decodesTo) -> SelectionSet typeLock decodesTo

#nonNullOrFail

nonNullOrFail :: forall lockedTo a. SelectionSet lockedTo (Maybe a) -> SelectionSet lockedTo a

#nonNullElementsOrFail

nonNullElementsOrFail :: forall lockedTo a. SelectionSet lockedTo (Array (Maybe a)) -> SelectionSet lockedTo (Array a)

#bindSelectionSet

bindSelectionSet :: forall lockedTo a b. (a -> Either JsonDecodeError b) -> SelectionSet lockedTo a -> SelectionSet lockedTo b

#getSelectionSetDecoder

getSelectionSetDecoder :: forall lockedTo a. SelectionSet lockedTo a -> Json -> Either JsonDecodeError a

#enumDecoder

Modules