Module

Prospero

Package
purescript-prospero
Repository
rowtype-yoga/purescript-prospero

Re-exports from Prospero.Bun

#serve Source

serve :: forall ctx errs gql. GraphQL ctx errs gql -> (forall a. Om ctx errs a -> Aff a) -> SubscriptionHandler -> { port :: Int } -> Effect BunServer

Re-exports from Prospero.CacheControl

#cacheControlFor Source

cacheControlFor :: forall ctx errs gql. { query :: GqlType | gql } -> Wrapper ctx errs

#cacheControl Source

cacheControl :: forall ctx errs. GqlType -> Wrapper ctx errs

Re-exports from Prospero.Client

#Selection Source

newtype Selection :: Type -> Type -> Row Type -> Typenewtype Selection (parent :: Type) (result :: Type) (params :: Row Type)

Constructors

#ClientError Source

type ClientError = { message :: String }

#withArgs Source

withArgs :: forall args parent result params. WriteForeign (Record args) => Record args -> Selection parent result params -> Selection parent result params

#selection Source

selection :: forall @q @fields qRow qRL resultRL paramsRL result params. RecordRow q qRow => RowToList qRow qRL => ParseGql fields "Query" qRL resultRL paramsRL => ListToRow resultRL result => ListToRow paramsRL params => IsSymbol fields => Selection q (Record result) params

#runSelectionWith Source

runSelectionWith :: forall @a result params. ReadForeign { data :: Maybe (Record result), errors :: Maybe (Array ClientError) } => WriteForeign (Record params) => String -> String -> Record params -> Selection a (Record result) params -> Aff (QueryResult result)

#runSelection Source

runSelection :: forall @a result params. ReadForeign { data :: Maybe (Record result), errors :: Maybe (Array ClientError) } => WriteForeign (Record params) => String -> Record params -> Selection a (Record result) params -> Aff (QueryResult result)

#runQuery Source

runQuery :: forall @q @fields qRow qRL resultRL paramsRL result params. RecordRow q qRow => RowToList qRow qRL => ParseGql fields "Query" qRL resultRL paramsRL => ListToRow resultRL result => ListToRow paramsRL params => WriteForeign (Record params) => ReadForeign { data :: Maybe (Record result), errors :: Maybe (Array ClientError) } => IsSymbol fields => String -> Record params -> Aff (QueryResult result)

#runMutationSelection Source

runMutationSelection :: forall @a result params. ReadForeign { data :: Maybe (Record result), errors :: Maybe (Array ClientError) } => WriteForeign (Record params) => String -> Record params -> Selection a (Record result) params -> Aff (QueryResult result)

#runMutation Source

runMutation :: forall @q @fields qRow qRL resultRL paramsRL result params. RecordRow q qRow => RowToList qRow qRL => ParseGql fields "Mutation" qRL resultRL paramsRL => ListToRow resultRL result => ListToRow paramsRL params => WriteForeign (Record params) => ReadForeign { data :: Maybe (Record result), errors :: Maybe (Array ClientError) } => IsSymbol fields => String -> Record params -> Aff (QueryResult result)

#mutationSelection Source

mutationSelection :: forall @q @fields qRow qRL resultRL paramsRL result params. RecordRow q qRow => RowToList qRow qRL => ParseGql fields "Mutation" qRL resultRL paramsRL => ListToRow resultRL result => ListToRow paramsRL params => IsSymbol fields => Selection q (Record result) params

Re-exports from Prospero.DataLoader

#DataLoader Source

newtype DataLoader k v

A DataLoader batches and caches individual key lookups. Create one per request to avoid stale caches across requests.

#mkDataLoader Source

mkDataLoader :: forall k v. Ord k => (Array k -> Aff (Map k v)) -> Aff (DataLoader k v)

Create a new DataLoader with a batch function.

#load Source

load :: forall k v. Ord k => DataLoader k v -> k -> Aff v

Load a single key. Batches with other concurrent loads and caches the result.

Re-exports from Prospero.Defer

#DeferredResponse Source

type DeferredResponse :: Type -> Row Type -> Typetype DeferredResponse ctx errs = { deferred :: Array (DeferPatch ctx errs), hasDeferred :: Boolean, initial :: Om ctx errs GraphQLResponse }

#DeferPatch Source

type DeferPatch :: Type -> Row Type -> Typetype DeferPatch ctx errs = { execute :: Om ctx errs GraphQLResponse, label :: Maybe String, path :: Array String }

#executeWithDefer Source

executeWithDefer :: forall ctx errs gql. GraphQL ctx errs gql -> String -> Map String InputValue -> DeferredResponse ctx errs

Re-exports from Prospero.Directive

#CustomDirective Source

type CustomDirective :: Type -> Row Type -> Typetype CustomDirective ctx errs = { apply :: Map String InputValue -> Om ctx errs ResponseValue -> Om ctx errs ResponseValue, args :: Array GqlInputValue, description :: Maybe String, locations :: Array DirectiveLocation, name :: String }

#withDirectives Source

withDirectives :: forall ctx errs gql. Array (CustomDirective ctx errs) -> Schema ctx errs gql -> Schema ctx errs gql

Re-exports from Prospero.Fastify

#SimpleErrs Source

type SimpleErrs :: Row Typetype SimpleErrs = (wrongArgumentType :: String)

#serveGraphQL Source

serveGraphQL :: forall ctxRow errs gql r rl err_ outerRow extra errs'. RowToList (exception :: Error -> Aff GraphQLResponse | r) rl => VariantMatchCases rl err_ (Aff GraphQLResponse) => Union err_ () (exception :: Error | errs) => Union ctxRow extra outerRow => Keys ctxRow => GraphQL (Record ctxRow) errs gql -> { exception :: Error -> Aff GraphQLResponse | r } -> Fastify -> Om (Record outerRow) errs' Unit

#runSimple Source

runSimple :: forall a. Om (Record ()) SimpleErrs a -> Aff a

#runServeGraphQL Source

runServeGraphQL :: forall ctx errs gql r rl err_. RowToList (exception :: Error -> Aff GraphQLResponse | r) rl => VariantMatchCases rl err_ (Aff GraphQLResponse) => Union err_ () (exception :: Error | errs) => GraphQL ctx errs gql -> ctx -> { exception :: Error -> Aff GraphQLResponse | r } -> Fastify -> Effect Unit

Re-exports from Prospero.Federation

#EntityResolvers Source

type EntityResolvers :: Type -> Row Type -> Typetype EntityResolvers ctx errs = Map String (EntityDef ctx errs)

#EntityResolver Source

type EntityResolver :: Type -> Row Type -> Typetype EntityResolver ctx errs = Map String InputValue -> Step ctx errs

#EntityDef Source

type EntityDef :: Type -> Row Type -> Typetype EntityDef ctx errs = { keys :: Array String, resolver :: EntityResolver ctx errs }

Re-exports from Prospero.GqlQuery

#Subscription Source

data Subscription result

#Query Source

data Query args result

#Mutation Source

data Mutation args result

Re-exports from Prospero.GraphQLError

#GraphQLResponse Source

type GraphQLResponse = { data :: ResponseValue, errors :: Array GraphQLError, extensions :: Object ResponseValue }

#GraphQLError Source

type GraphQLError = { extensions :: Object ResponseValue, locations :: Array SourceLocation, message :: String, path :: Array PathSegment }

Re-exports from Prospero.GraphQLWS

#SubscriptionHandler Source

type SubscriptionHandler = { fieldName :: String, selections :: Array Selection, send :: ResponseValue -> Effect Unit } -> Effect (Effect Unit)

#handleGraphQLWS Source

handleGraphQLWS :: forall ctx errs gql. GraphQL ctx errs gql -> (forall a. Om ctx errs a -> Aff a) -> SubscriptionHandler -> WebSocket -> Effect { onClose :: Effect Unit, onMessage :: String -> Effect Unit }

Re-exports from Prospero.Http

#queryWith Source

queryWith :: forall ctx errs gql. Array (Wrapper ctx errs) -> GraphQL ctx errs gql -> String -> Om ctx errs GraphQLResponse

Execute a GraphQL query string with wrappers

#query Source

query :: forall ctx errs gql. GraphQL ctx errs gql -> String -> Om ctx errs GraphQLResponse

Execute a GraphQL query string against a schema

#executeRequestWith Source

executeRequestWith :: forall ctx errs gql. Array (Wrapper ctx errs) -> GraphQL ctx errs gql -> GraphQLRequest -> Om ctx errs GraphQLResponse

Execute a GraphQL request with wrappers applied

#executeRequest Source

executeRequest :: forall ctx errs gql. GraphQL ctx errs gql -> GraphQLRequest -> Om ctx errs GraphQLResponse

Execute a GraphQL request against a schema, returning a structured response

Re-exports from Prospero.InputValue

#newtypeFromInputValue Source

Re-exports from Prospero.Metadata

#Union Source

data Union

#TimeUnit Source

#Seconds Source

#Scalar Source

data Scalar

#Object Source

data Object

#Named Source

newtype Named :: Symbol -> Type -> Typenewtype Named gqlName a

Instances

#Name Source

newtype Name :: Symbol -> Type -> Typenewtype Name name a

Instances

#Minutes Source

#MaxAge Source

newtype MaxAge :: Int -> TimeUnit -> Type -> Typenewtype MaxAge n unit a

Instances

#Interface Source

#InputObject Source

#Hours Source

data Hours :: TimeUnitdata Hours

Instances

#GqlUnion_ Source

newtype GqlUnion_ :: Symbol -> Type -> Typenewtype GqlUnion_ name a

Constructors

Instances

#GqlObject_ Source

newtype GqlObject_ :: Symbol -> Type -> Typenewtype GqlObject_ name a

Constructors

Instances

#GqlInputObject_ Source

newtype GqlInputObject_ :: Symbol -> Type -> Typenewtype GqlInputObject_ name a

Constructors

Instances

#GqlEnum_ Source

newtype GqlEnum_ :: Symbol -> Type -> Typenewtype GqlEnum_ name a

Constructors

Instances

#Excluded Source

newtype Excluded a

Instances

#Enum Source

data Enum

#Described Source

#Deprecated Source

newtype Deprecated :: Symbol -> Type -> Typenewtype Deprecated reason a

Instances

#Cost Source

newtype Cost :: Int -> Type -> Typenewtype Cost cost a

Instances

#IsGql Source

class IsGql :: Type -> Symbol -> Type -> Constraintclass IsGql kind name a | a -> kind name

#private Source

private :: forall a. a -> Private a

#named Source

named :: forall @gqlName a. a -> Named gqlName a

#nameType Source

nameType :: forall @name a. a -> Name name a

#maxAge Source

maxAge :: forall @n @unit a. a -> MaxAge n unit a

#excluded Source

excluded :: forall a. a -> Excluded a

#described Source

described :: forall @desc a. a -> Described desc a

#deprecated Source

deprecated :: forall @reason a. a -> Deprecated reason a

#cost Source

cost :: forall @cost a. a -> Cost cost a

Re-exports from Prospero.PersistedQueries

#PersistedQueryCache Source

#persistedQueries Source

persistedQueries :: forall ctx errs gql. PersistedQueryCache -> (GraphQL ctx errs gql -> GraphQLRequest -> Om ctx errs GraphQLResponse) -> GraphQL ctx errs gql -> GraphQLRequest -> ResponseValue -> Om ctx errs GraphQLResponse

Re-exports from Prospero.Relay

#PageInfoRecord Source

type PageInfoRecord = { endCursor :: Maybe String, hasNextPage :: Boolean, hasPreviousPage :: Boolean, startCursor :: Maybe String }

#PageInfo Source

#Edge Source

newtype Edge a

Constructors

Instances

#ConnectionArgs Source

type ConnectionArgs = { after :: Maybe String, before :: Maybe String, first :: Maybe Int, last :: Maybe Int }

#Connection Source

newtype Connection a

Constructors

Instances

#mkConnection Source

mkConnection :: forall a. { edges :: Array (Edge a), hasNextPage :: Boolean, hasPreviousPage :: Boolean, totalCount :: Maybe Int } -> Connection a

#emptyConnection Source

#connectionFromArray Source

Re-exports from Prospero.ResponseValue

Re-exports from Prospero.RootResolver

#GraphQL Source

type GraphQL :: Type -> Row Type -> Type -> Typetype GraphQL ctx errs schemaGql = { mutation :: Maybe GqlType, mutationStep :: Maybe (Step ctx errs), query :: GqlType, queryStep :: Step ctx errs, subscription :: Maybe GqlType, subscriptionStep :: Maybe (Step ctx errs) }

#ImplType Source

class ImplType :: Type -> Row Type -> RowList Type -> Row Type -> Constraintclass ImplType (ctx :: Type) (errs :: Row Type) (schemaRL :: RowList Type) (implRow :: Row Type) | ctx errs schemaRL -> implRow

Derives the Om-wrapped implementation row from a pure schema row. Plain fields get wrapped in Om, function fields get their return type wrapped.

Instances

#RecordRow Source

class RecordRow :: Type -> Row Type -> Constraintclass RecordRow (rec :: Type) (row :: Row Type) | rec -> row

Extracts the row from a Record type

Instances

#withFederation Source

withFederation :: forall ctx errs gql. EntityResolvers ctx errs -> GraphQL ctx errs gql -> GraphQL ctx errs gql

#mkGraphQL' Source

mkGraphQL' :: forall ctx errs q qGql. GqlSchema ctx errs (Record q) qGql => { introspection :: Boolean } -> Record q -> GraphQL ctx errs qGql

#mkGraphQL Source

mkGraphQL :: forall ctx errs q qGql. GqlSchema ctx errs (Record q) qGql => Record q -> GraphQL ctx errs qGql

#graphql Source

graphql :: forall @schema schemaRow schemaRL ctx errs implRow qRow mRow sRow qGql mGql sGql. RecordRow schema schemaRow => RowToList schemaRow schemaRL => SplitSchema ctx errs schemaRL implRow qRow mRow sRow => GqlSchema ctx errs (Record qRow) qGql => GqlSchema ctx errs (Record mRow) mGql => GqlSchema ctx errs (Record sRow) sGql => Record implRow -> GraphQL ctx errs qGql

#executeQuery Source

executeQuery :: forall ctx errs schemaGql. GraphQL ctx errs schemaGql -> Array Selection -> Om ctx errs ResponseValue

#executeOperation Source

executeOperation :: forall ctx errs schemaGql. GraphQL ctx errs schemaGql -> ParsedOperation -> Om ctx errs ResponseValue

Re-exports from Prospero.SDL

#toSDL Source

toSDL :: forall r. { mutation :: Maybe GqlType, query :: GqlType, subscription :: Maybe GqlType | r } -> String

#federationSDL Source

federationSDL :: forall r. { mutation :: Maybe GqlType, query :: GqlType, subscription :: Maybe GqlType | r } -> String

Re-exports from Prospero.Scalars

#ID Source

newtype ID

GraphQL ID scalar — accepts both String and Int inputs

Constructors

Instances

Re-exports from Prospero.Schema

#GqlSchema Source

class GqlSchema :: Type -> Row Type -> Type -> Type -> Constraintclass GqlSchema ctx errs a gql | a -> gql

Maps a PureScript type to its GraphQL type-level representation and runtime behavior. The fundep a -> gql means the GraphQL schema shape is fully determined by the PureScript type.

Instances

#genericFromInputValue Source

Re-exports from Prospero.Subscription

#EventSource Source

newtype EventSource a

An EventSource emits values to subscribers.

#subscribe Source

subscribe :: forall a m. MonadEffect m => EventSource a -> (a -> Effect Unit) -> m (Effect Unit)

Subscribe to an EventSource. Returns an unsubscribe effect.

#mkEventSource Source

mkEventSource :: forall a m. MonadEffect m => m (EventSource a)

Create a new EventSource.

#emit Source

emit :: forall a m. MonadEffect m => EventSource a -> a -> m Unit

Emit a value to all current subscribers.

Re-exports from Prospero.Tracing

#apolloTracing Source

apolloTracing :: forall ctx errs. Effect (Array (Wrapper ctx errs))

Re-exports from Prospero.Types

#GqlType Source

data GqlType

Constructors

#GqlInputValue Source

type GqlInputValue = { defaultValue :: Maybe String, description :: Maybe String, name :: String, type :: GqlType }

#GqlField Source

type GqlField = { args :: Array GqlInputValue, cost :: Int, deprecationReason :: Maybe String, description :: Maybe String, isDeprecated :: Boolean, isPrivate :: Boolean, maxAge :: Maybe Seconds, name :: String, type :: GqlType }

Re-exports from Prospero.Upload

#Upload Source

newtype Upload

Upload scalar for GraphQL file uploads. At the schema level, Upload is a String scalar (filename). Actual file data is injected by the multipart HTTP handler.

Constructors

Instances

Re-exports from Prospero.WebSocket

#WebSocket Source

Re-exports from Prospero.Wrapper

#Wrapper Source

data Wrapper :: Type -> Row Type -> Typedata Wrapper ctx errs

A collection of wrappers that can be applied to a schema

#FieldWrapper Source

data FieldWrapper :: Type -> Row Type -> Typedata FieldWrapper ctx errs

Field wrapper: wraps individual field resolution

Constructors

#validateLimitsFor Source

validateLimitsFor :: forall ctx errs gql. { query :: GqlType | gql } -> { maxCost :: Maybe Int, maxDepth :: Maybe Int, maxFields :: Maybe Int } -> Wrapper ctx errs

#validateLimits Source

validateLimits :: forall ctx errs. GqlType -> { maxCost :: Maybe Int, maxDepth :: Maybe Int, maxFields :: Maybe Int } -> Wrapper ctx errs

Pre-built wrapper: check depth, field count, and cost in a single pass

#timeout Source

timeout :: forall ctx errs. Int -> Wrapper ctx errs

Pre-built wrapper: apply a timeout to execution (in milliseconds)

#maxFields Source

maxFields :: forall ctx errs. Int -> Wrapper ctx errs

Pre-built wrapper: reject queries with more than maxFields total fields

#maxDepth Source

maxDepth :: forall ctx errs. Int -> Wrapper ctx errs

Pre-built wrapper: reject queries deeper than maxDepth

#maxCostFor Source

maxCostFor :: forall ctx errs gql. { query :: GqlType | gql } -> Int -> Wrapper ctx errs

#maxCost Source

maxCost :: forall ctx errs. GqlType -> Int -> Wrapper ctx errs

Pre-built wrapper: reject queries exceeding a cost budget

#logSlowFields Source

logSlowFields :: forall ctx errs. Int -> Wrapper ctx errs

Pre-built wrapper: log fields that take longer than a threshold (in milliseconds)

Re-exports from Yoga.Om

#Om Source

newtype Om :: Type -> Row Type -> Type -> Typenewtype Om ctx err a

"dependency injection" via ReaderT which tracks a context, and checked exceptions and early return with ExceptV.

Instances

#toOm Source

toOm :: forall f ctx err a. ToOm f => f a -> Om ctx err a

#runOm Source

runOm :: forall ctx r rl err_ err a. RowToList (exception :: Error -> Aff a | r) rl => VariantMatchCases rl err_ (Aff a) => Union err_ () (Exception err) => ctx -> { exception :: Error -> Aff a | r } -> Om ctx err a -> Aff a

Invoke this function in the end and handle all possible errors, e.g.

runOm { token: "123" } { someError: \e -> handleTheError e } someApp

#inParallel Source

inParallel :: forall ctx e a. Array (Om ctx e a) -> Om ctx e (Array a)

Run multiple Oms in parallel, and collect all results To only take the fastest result, use race

#ask Source

ask :: forall r m. MonadAsk r m => m r