graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hasura.GraphQL.Schema

Synopsis

Documentation

buildGQLContext :: forall m. (MonadError QErr m, MonadIO m) => InferFunctionPermissions -> RemoteSchemaPermissions -> HashSet ExperimentalFeature -> SQLGenCtx -> ApolloFederationStatus -> SourceCache -> HashMap RemoteSchemaName (RemoteSchemaCtx, MetadataObject) -> ActionCache -> AnnotatedCustomTypes -> Maybe SchemaRegistryContext -> Logger Hasura -> m ((SchemaIntrospection, HashMap RoleName (RoleContext GQLContext), GQLContext, HashSet InconsistentMetadata), (HashMap RoleName (RoleContext GQLContext), GQLContext), SchemaRegistryAction) Source #

Builds the full GraphQL context for a given query type.

A GQLContext stores how an incoming request should be processed: how to translate each incoming field of a request into a corresponding semantic representation. There is a different one per Role, as each role might have different permissions, and therefore not access to the same set of objects in the schema.

This function takes all necessary information from the metadata, and the GraphQLQueryType, and builds all relevant contexts: a hash map from RoleName to their GQLContext and the "default" context for unauthenticated users.

When building the schema for each role, we treat the remote schemas as "second-class citizens" compared to sources; more specifically, we attempt to detect whether the inclusion of a given remote schema would result in root fields conflict, and only keep schemas that don't generate any. This results in a partial schema being available to the users, and a better error message than would arise from safeSelectionSet.