Module

GraphQLClient.Implementation

Package
purescript-graphqlclient
Repository
purescript-graphqlclient/purescript-graphqlclient

#Scope__RootQuery Source

#Scope__RootMutation Source

#Scope__RootSubscription Source

#SelectionSet Source

data SelectionSet parentTypeLock a

Constructors

Instances

#map2 Source

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

#foldl Source

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

#FragmentSelectionSet Source

#fieldNameWithHash Source

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 Source

#selectionForFieldImplementation Source

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

#selectionForField Source

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

#selectionForCompositeFieldImplementation Source

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 Source

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

#buildFragment Source

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

#exhaustiveFragmentSelection Source

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

#nonNullOrFail Source

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

#nonNullElementsOrFail Source

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

#bindSelectionSet Source

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

#getSelectionSetDecoder Source

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

#enumDecoder Source