graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.Server.OpenAPI

Synopsis

Documentation

buildAllEndpoints :: (MonadError QErr m, MonadFix m) => SchemaCache -> SchemaIntrospection -> DeclareM m (InsOrdHashMap String (PathItem, Text)) Source #

buildEndpoint :: (MonadError QErr m, MonadFix m) => SchemaIntrospection -> EndpointMethod -> EndpointMetadata GQLQueryWithText -> DeclareM m (InsOrdHashMap String (PathItem, Text)) Source #

collectParams :: Structure -> EndpointUrl -> [Referenced Param] Source #

Given the Structure of a query, generate the corresponding parameters.

We expect one optional parameter per known scalar variable.

buildRequestBody :: (MonadError QErr m, MonadFix m) => Structure -> DeclareM m (Maybe (Referenced RequestBody)) Source #

Given the Structure of a query, generate the corresponding RequestBody.

We always expect an object that has a field per variable of the query if there is at least one variable in the query; otherwise we don't expect a request body.

buildVariableSchema :: (MonadError QErr m, MonadFix m) => VariableInfo -> CircularT (Name, Nullability) (Referenced Schema) (DeclareM m) (Referenced Schema, Bool) Source #

Given the information about a variable, build the corresponding schema.

Returns the generated schema, and a boolean indicating whether the variable is required.

buildInputFieldSchema :: MonadFix m => GType -> InputFieldInfo -> CircularT (Name, Nullability) (Referenced Schema) (DeclareM m) (Referenced Schema) Source #

Given the information about an input type, build the corresponding schema.

buildResponse :: Monad m => Structure -> EndpointMethod -> Text -> DeclareM m Response Source #

Given the Structure of a query, generate the corresponding Response.

buildSelectionSchema :: Monad m => [(Name, FieldInfo)] -> DeclareM m Schema Source #

Given a list of fields and their types, build a corresponding schema.

buildFieldSchema :: Monad m => FieldInfo -> DeclareM m (Referenced Schema) Source #

Build the schema for a given output type.

buildScalarSchema :: Monad m => ScalarInfo -> Name -> Nullability -> DeclareM m (Referenced Schema) Source #

Craft the OpenAPI Schema for a given scalar. Any non-standard scalar will instead be declared, and returned by reference.

getReferenceScalarInfo :: Name -> Maybe (OpenApiType, Maybe Pattern, Bool) Source #

Retrieve info associated with a given scalar, if it can be mapped to a built-in OpenAPI scalar. On a match, we return a tuple indiciating which scalar should be used, a pattern, and a boolean indicating whether this type should be inlined.

buildEnumSchema :: Monad m => EnumInfo -> Name -> Nullability -> DeclareM m (Referenced Schema) Source #

Craft the OpenAPI Schema for a given enum.

applyModifiers :: Monad m => GType -> (Name -> Nullability -> m (Referenced Schema)) -> m (Referenced Schema) Source #

Given an annotated GraphQL type (such as [[Foo!]]! and a callback function to be used on the actual underlying type, construct a Schema by recursively applying modifiers.

declareType :: Monad m => Name -> Nullability -> Schema -> DeclareM m (Referenced Schema) Source #

Adds a declaration for the given type, returns a schema that references it.

mkReferenceName :: Name -> Nullability -> Text Source #

Crafts a reference name for a given type.

We use the fact that JSON references allow characters that GraphQL types don't: we make a different reference for non-nullable type by using the GraphQL convention of suffixing the name by !.

See Note [Nullable types in OpenAPI].

type DeclareM = DeclareT (Definitions Schema) Source #

xHasuraAdminSecret :: Param Source #

Variable definition for x-hasura-admin-secret

gqlToJsonValue :: Value Void -> Value Source #

Convert a GraphQL value to an equivalent JSON representation.

TODO: can we deduplicate this?