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:
- The root type names for query, mutation and subscription operations.
- The name for Model selection input field names (
where
,limit
,offset
,args
,order_by
) - The enum values for
order_by
directions and theorder_by
enum type name.
Metadata structure
GraphqlConfig
GraphqlConfig object tells us two things:
- 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
Key | Value | Required | Description |
---|---|---|---|
kind | GraphqlConfig | true | |
version | v1 | true | |
definition | GraphqlConfigV1 | true | 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 |
GraphqlConfigV1
GraphqlConfig object tells us two things:
- 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
Key | Value | Required | Description |
---|---|---|---|
query | QueryGraphqlConfig | true | Configuration for the GraphQL schema of Hasura features for queries. None means disable the feature. |
mutation | MutationGraphqlConfig | true | Configuration for the GraphQL schema of Hasura features for mutations. |
apolloFederation | GraphqlApolloFederationConfig / null | false |
GraphqlApolloFederationConfig
Configuration for the GraphQL schema of Hasura features for Apollo Federation.
Key | Value | Required | Description |
---|---|---|---|
enableRootFields | boolean | true | Adds the _entities and _services root fields required for Apollo Federation. |
MutationGraphqlConfig
Configuration for the GraphQL schema of Hasura features for mutations.
Key | Value | Required | Description |
---|---|---|---|
rootOperationTypeName | string | true | The 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.
Key | Value | Required | Description |
---|---|---|---|
rootOperationTypeName | string | true | The name of the root operation type name for queries. Usually query . |
argumentsInput | ArgumentsInputGraphqlConfig / null | false | Configuration for the arguments input. |
limitInput | LimitInputGraphqlConfig / null | false | Configuration for the limit operation. |
offsetInput | OffsetInputGraphqlConfig / null | false | Configuration for the offset operation. |
filterInput | FilterInputGraphqlConfig / null | false | Configuration for the filter operation. |
orderByInput | OrderByInputGraphqlConfig / null | false | Configuration for the sort operation. |
aggregate | AggregateGraphqlConfig / null | false | Configuration for aggregates |
AggregateGraphqlConfig
Key | Value | Required | Description |
---|---|---|---|
filterInputFieldName | GraphQlFieldName | true | The name of the filter input parameter of aggregate fields and field name in predicates |
countFieldName | GraphQlFieldName | true | The name of the _count field used for the count aggregate function |
countDistinctFieldName | GraphQlFieldName | true | The 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.
Key | Value | Required | Description |
---|---|---|---|
fieldName | string | true | The name of the filter operation field. Usually order_by . |
enumDirectionValues | OrderByDirectionValues | true | The names of the direction parameters. |
enumTypeNames | [OrderByEnumTypeName] | true |
OrderByEnumTypeName
Key | Value | Required | Description |
---|---|---|---|
directions | [OrderByDirection] | true | |
typeName | string | true |
OrderByDirection
Sort direction.
One of the following values:
Value | Description |
---|---|
Asc | Ascending. |
Desc | Descending. |
OrderByDirectionValues
The names of the direction parameters.
Key | Value | Required | Description |
---|---|---|---|
asc | string | true | The name of the ascending parameter. Usually Asc . |
desc | string | true | The name of the descending parameter. Usually Desc . |
FilterInputGraphqlConfig
Configuration for the filter operation.
Key | Value | Required | Description |
---|---|---|---|
fieldName | string | true | The name of the filter operation field. Usually where . |
operatorNames | FilterInputOperatorNames | true | The names of built-in filter operators. |
FilterInputOperatorNames
The names of built-in filter operators.
Key | Value | Required | Description |
---|---|---|---|
and | string | true | The name of the and operator. Usually _and . |
or | string | true | The name of the or operator. Usually _or . |
not | string | true | The name of the not operator. Usually _not . |
isNull | string | true | The name of the is null operator. Usually _is_null . |
OffsetInputGraphqlConfig
Configuration for the offset operation.
Key | Value | Required | Description |
---|---|---|---|
fieldName | string | true | The name of the offset operation field. Usually offset . |
LimitInputGraphqlConfig
Configuration for the limit operation.
Key | Value | Required | Description |
---|---|---|---|
fieldName | string | true | The name of the limit operation field. Usually limit . |
ArgumentsInputGraphqlConfig
Configuration for the arguments input.
Key | Value | Required | Description |
---|---|---|---|
fieldName | string | true | The name of arguments passing field. Usually args . |