Skip to main content
Version: v3.x

Configuration for GraphQL API

Introduction

The GraphqlConfig object allows you to configure the GraphQL schema generated by Hasura. This object helps you configure the common GraphQL schema applicable to all subgraphs within a project.

The GraphqlConfig object belongs to the supergraph and can be defined once across your supergraph in any subgraph of your choice.

By default, all projects are created with a default GraphqlConfig object in the globals subgraph.

Specifically, it allows you to configure:

  1. The root type names for query, mutation and subscription operations.
  2. The name for Model selection input field names (where, limit, offset, args, order_by)
  3. The enum values for order_by directions and the order_by enum type name.

Metadata structure

GraphqlConfig

GraphqlConfig object tells us two things:

  1. How the Graphql schema should look like for the features (where, order_by etc) Hasura provides 2. What features should be enabled/disabled across the subgraphs
KeyValueRequiredDescription
kindGraphqlConfigtrue
versionv1true
definitionGraphqlConfigV1trueGraphqlConfig object tells us two things: 1. How the Graphql schema should look like for the features (where, order_by etc) Hasura provides 2. What features should be enabled/disabled across the subgraphs

GraphqlConfigV1

GraphqlConfig object tells us two things:

  1. How the Graphql schema should look like for the features (where, order_by etc) Hasura provides 2. What features should be enabled/disabled across the subgraphs
KeyValueRequiredDescription
queryQueryGraphqlConfigtrueConfiguration for the GraphQL schema of Hasura features for queries. None means disable the feature.
mutationMutationGraphqlConfigtrueConfiguration for the GraphQL schema of Hasura features for mutations.
apolloFederationGraphqlApolloFederationConfig / nullfalse

GraphqlApolloFederationConfig

Configuration for the GraphQL schema of Hasura features for Apollo Federation.

KeyValueRequiredDescription
enableRootFieldsbooleantrueAdds the _entities and _services root fields required for Apollo Federation.

MutationGraphqlConfig

Configuration for the GraphQL schema of Hasura features for mutations.

KeyValueRequiredDescription
rootOperationTypeNamestringtrueThe name of the root operation type name for mutations. Usually mutation.

QueryGraphqlConfig

Configuration for the GraphQL schema of Hasura features for queries. None means disable the feature.

KeyValueRequiredDescription
rootOperationTypeNamestringtrueThe name of the root operation type name for queries. Usually query.
argumentsInputArgumentsInputGraphqlConfig / nullfalseConfiguration for the arguments input.
limitInputLimitInputGraphqlConfig / nullfalseConfiguration for the limit operation.
offsetInputOffsetInputGraphqlConfig / nullfalseConfiguration for the offset operation.
filterInputFilterInputGraphqlConfig / nullfalseConfiguration for the filter operation.
orderByInputOrderByInputGraphqlConfig / nullfalseConfiguration for the sort operation.
aggregateAggregateGraphqlConfig / nullfalseConfiguration for aggregates

AggregateGraphqlConfig

KeyValueRequiredDescription
filterInputFieldNameGraphQlFieldNametrueThe name of the filter input parameter of aggregate fields and field name in predicates
countFieldNameGraphQlFieldNametrueThe name of the _count field used for the count aggregate function
countDistinctFieldNameGraphQlFieldNametrueThe name of the _count_distinct field used for the count distinct aggregate function

GraphQlFieldName

The name of a GraphQL object field.

Value: string

OrderByInputGraphqlConfig

Configuration for the sort operation.

KeyValueRequiredDescription
fieldNamestringtrueThe name of the filter operation field. Usually order_by.
enumDirectionValuesOrderByDirectionValuestrueThe names of the direction parameters.
enumTypeNames[OrderByEnumTypeName]true

OrderByEnumTypeName

KeyValueRequiredDescription
directions[OrderByDirection]true
typeNamestringtrue

OrderByDirection

Sort direction.

One of the following values:

ValueDescription
AscAscending.
DescDescending.

OrderByDirectionValues

The names of the direction parameters.

KeyValueRequiredDescription
ascstringtrueThe name of the ascending parameter. Usually Asc.
descstringtrueThe name of the descending parameter. Usually Desc.

FilterInputGraphqlConfig

Configuration for the filter operation.

KeyValueRequiredDescription
fieldNamestringtrueThe name of the filter operation field. Usually where.
operatorNamesFilterInputOperatorNamestrueThe names of built-in filter operators.

FilterInputOperatorNames

The names of built-in filter operators.

KeyValueRequiredDescription
andstringtrueThe name of the and operator. Usually _and.
orstringtrueThe name of the or operator. Usually _or.
notstringtrueThe name of the not operator. Usually _not.
isNullstringtrueThe name of the is null operator. Usually _is_null.

OffsetInputGraphqlConfig

Configuration for the offset operation.

KeyValueRequiredDescription
fieldNamestringtrueThe name of the offset operation field. Usually offset.

LimitInputGraphqlConfig

Configuration for the limit operation.

KeyValueRequiredDescription
fieldNamestringtrueThe name of the limit operation field. Usually limit.

ArgumentsInputGraphqlConfig

Configuration for the arguments input.

KeyValueRequiredDescription
fieldNamestringtrueThe name of arguments passing field. Usually args.
Loading...