Skip to main content
Version: v3.x

Data Connector Links

Introduction

A DataConnectorLink is a used to specify the URLs and NDC schema of a data connector allowing to link it to models and commands. It can be used to connect to various types of data connectors on different data sources, like SQL databases, NoSQL databases, REST APIs, GraphQL APIs, files, and more.

Lifecycle

A DataConnectorLink can be created using the CLI. Out of convenience, the CLI will scaffold this file automatically for you when initializing a new connector.

A DataConnectorLink belongs to a single subgraph and represents a connection to a data source. It is used to link the data source to the subgraph's models, commands, and relationships. The contents can be updated using the CLI. This will introspect the data source and update the schema of the data connector.

Any time your data source schema changes, you should update the DataConnectorLink to reflect those changes. This will ensure that the schema of the data connector is up to date and that the data connector can be used to serve requests.

This configuration is then used to generate the metadata representing collections present in the data source.

Be more granular

The example we linked above is for adding all models, commands, and relationships present in a data source. However, you can add each resource individually after updating the DataConnectorLink configuration:

To make a new data connector link and it's cascading metadata available in your supergraph, you'll need to create a new build using the CLI after adding your resources.

Examples

A sample DataConnectorLink:
kind: DataConnectorLink
version: v1
definition:
name: data_connector
url:
singleUrl:
value: http://data_connector:8100
headers: {}
schema:
version: v0.1
schema:
scalar_types: {}
object_types: {}
collections: []
functions: []
procedures: []
capabilities:
version: 0.1.3
capabilities:
query:
nested_fields: {}
variables: {}
mutation: {}
FieldDescriptionReference
kindSpecifies the type of configuration, in this case, DataConnectorLink.DataConnectorLink
versionThe version of the DataConnectorLink configuration, which is v1.DataConnectorLinkV1
definition.nameThe name given to this data connector configuration.DataConnectorName
definition.url.singleUrl.valueThe URL used to access the data connector.DataConnectorUrlV1
definition.headersA key-value map of HTTP headers to be sent with each request to the data connector.HttpHeaders
definition.schema.versionThe version of the schema that the data connector is using.SchemaAndCapabilitiesV01
definition.schema.schema[]The schema of the data connector, representing various types, collections, functions, and procedures.SchemaAndCapabilitiesV01
definition.schema.capabilities.versionThe version of the capabilities that the data connector supports.SchemaAndCapabilitiesV01
definition.schema.capabilities.capabilities.queryThe query capabilities of the data connector.SchemaAndCapabilitiesV01
definition.schema.capabilities.capabilities.mutationThe mutation capabilities of the data connector.SchemaAndCapabilitiesV01

Metadata structure

Definition of a data connector, used to bring in sources of data and connect them to OpenDD models and commands.

KeyValueRequiredDescription
kindDataConnectorLinktrue
versionv1true
definitionDataConnectorLinkV1trueDefinition of a data connector - version 1.

Example:

kind: DataConnectorLink
version: v1
definition:
name: data_connector
url:
singleUrl:
value: http://data_connector:8100
headers: {}
schema:
version: v0.1
schema:
scalar_types: {}
object_types: {}
collections: []
functions: []
procedures: []
capabilities:
version: 0.1.3
capabilities:
query:
nested_fields: {}
variables: {}
mutation: {}

Definition of a data connector - version 1.

KeyValueRequiredDescription
nameDataConnectorNametrueThe name of the data connector.
urlDataConnectorUrlV1trueThe url(s) to access the data connector.
headersHttpHeadersfalseKey value map of HTTP headers to be sent with each request to the data connector. This is meant for protocol level use between engine and the data connector.
schemaSchemaAndCapabilitiesV01trueThe schema of the data connector. This schema is used as the source of truth when serving requests and the live schema of the data connector is not looked up.
argumentPresets[DataConnectorArgumentPreset]falseArgument presets that applies to all functions and procedures of this data connector. Defaults to no argument presets.
responseHeadersResponseHeaders / nullfalseHTTP response headers configuration that is forwarded from a data connector to the client.

Configuration of what HTTP response headers should be forwarded from a data connector to the client in HTTP response.

KeyValueRequiredDescription
headersFieldDataConnectorColumnNametrueName of the field in the NDC function/procedure's result which contains the response headers
resultFieldDataConnectorColumnNametrueName of the field in the NDC function/procedure's result which contains the result
forwardHeaders[string]trueList of actual HTTP response headers from the data connector to be set as response headers

The name of a column in a data connector.

Value: string

An argument preset that can be applied to all functions/procedures of a connector

KeyValueRequiredDescription
argumentDataConnectorArgumentNametrueThe name of an argument as defined by a data connector.
valueDataConnectorArgumentPresetValuetrueThe value of a data connector argument preset.

The value of a data connector argument preset.

KeyValueRequiredDescription
httpHeadersHttpHeadersPresettrueHTTP headers that can be preset from request

Configuration of what HTTP request headers should be forwarded to a data connector.

KeyValueRequiredDescription
forward[string]trueList of HTTP headers that should be forwarded from HTTP requests
additionalAdditionalHttpHeaderstrueAdditional headers that should be forwarded, from other contexts

Key value map of HTTP headers to be forwarded in the headers argument of a data connector request.

KeyValueRequiredDescription
<customKey>ValueExpressionfalse

An expression which evaluates to a value that can be used in permissions and various presets.

Must have exactly one of the following fields:

KeyValueRequiredDescription
literalfalse
sessionVariablestringfalse

The name of an argument as defined by a data connector.

Value: string

Version 0.1 of schema and capabilities for a data connector.

KeyValueRequiredDescription
versionv0.1true
schemaSchema Responsetrue
capabilitiesCapabilities Responsetrue

Key value map of HTTP headers to be sent with an HTTP request. The key is the header name and the value is a potential reference to an environment variable.

KeyValueRequiredDescription
<customKey>EnvironmentValuefalse

A URL to access a data connector. This can be a single URL or a pair of read and write URLs.

Must have exactly one of the following fields:

KeyValueRequiredDescription
singleUrlEnvironmentValuefalse
readWriteUrlsReadWriteUrlsfalseA pair of URLs to access a data connector, one for reading and one for writing.

A pair of URLs to access a data connector, one for reading and one for writing.

KeyValueRequiredDescription
readEnvironmentValuetrue
writeEnvironmentValuetrue

Either a literal string or a reference to a Hasura secret

Must have exactly one of the following fields:

KeyValueRequiredDescription
valuestringfalse
valueFromEnvstringfalse

The name of a data connector.

Value: string

DataConnectorScalarRepresentation

The representation of a data connector scalar in terms of Open DD types

KeyValueRequiredDescription
kindDataConnectorScalarRepresentationtrue
versionv1true
definitionDataConnectorScalarRepresentationV1trueThe representation of a data connector scalar in terms of Open DD types. Deprecated in favour of BooleanExpressionType.

DataConnectorScalarRepresentationV1

The representation of a data connector scalar in terms of Open DD types. Deprecated in favour of BooleanExpressionType.

KeyValueRequiredDescription
dataConnectorNameDataConnectorNametrueThe name of the data connector that this scalar type comes from.
dataConnectorScalarTypeDataConnectorScalarTypetrueThe name of the scalar type coming from the data connector.
representationTypeNametrueThe name of the Open DD type that this data connector scalar type should be represented as.
graphqlDataConnectorScalarGraphQLConfiguration / nullfalseConfiguration for how this scalar's operators should appear in the GraphQL schema.

Example:

dataConnectorName: data_connector
dataConnectorScalarType: varchar
representation: String
graphql:
comparisonExpressionTypeName: String_Comparison_Exp

DataConnectorScalarGraphQLConfiguration

GraphQL configuration of a data connector scalar

KeyValueRequiredDescription
comparisonExpressionTypeNameGraphQlTypeName / nullfalse

GraphQlTypeName

The name of a GraphQL type.

Value: string

TypeName

The name of the Open DD type that this data connector scalar type should be represented as.

One of the following values:

ValueDescription
InbuiltTypeAn inbuilt primitive OpenDD type.
CustomTypeName

CustomTypeName

The name of a user-defined type.

Value: string

InbuiltType

An inbuilt primitive OpenDD type.

Value: ID / Int / Float / Boolean / String

DataConnectorScalarType

The name of a scalar type in a data connector.

Value: string

DataConnectorName

The name of a data connector.

Value: string