Object Types

This reference doc is generated based on this example schema.

Object types define a collection of fields representing an entity in a GraphQL schema.

Developer defines @table types and Data Connect generates queries and mutations based on them.

Developer Defined Plus Data Connect Generated

type MainTable

🔨 MainTable is an example of developer defined table type to demonstrate various supported column types in a Postgres table.

type MainTable @table {
  uuidField: UUID
  stringField: String
  intField: Int
  int64Field: Int64
  floatField: Float
  booleanField: Boolean
  dateField: Date
  timestampField: Timestamp
  anyField: Any
  vectorField: Vector @col(size: 768)
}

@table(key) defines the primary key. If not configured otherwise, uses the primary key field id. If the id field isn't present already, Data Connect implicitly adds an auto-generated UUID primary key field: id: UUID! @default(expr: "uuidV4()")

Field Type Description
uuidField UUID 🔨 uuidField is an example of developer defined column as uuid type.
stringField String 🔨 stringField is an example of developer defined column as text type.
intField Int 🔨 intField is an example of developer defined column as int type.
int64Field Int64 🔨 int64Field is an example of developer defined column as bigint type.
floatField Float 🔨 floatField is an example of developer defined column as double precision type.
booleanField Boolean 🔨 booleanField is an example of developer defined column as boolean type.
dateField Date 🔨 dateField is an example of developer defined column as date type.
timestampField Timestamp 🔨 timestampField is an example of developer defined column as timestamptz type.
anyField Any 🔨 anyField is an example of developer defined column as jsonb type.
vectorField Vector 🔨 vectorField is an example of developer defined column as pgvector type. @col(size: 768) defines its length to work with google_ml_integration Postgres extensions in your Cloud SQL someFieldbase.
uuidArray [UUID] 🔨 uuidArray is an example of developer defined column as uuid[] array type.
stringArray [String] 🔨 stringArray is an example of developer defined column as text[] array type.
intArray [Int] 🔨 intArray is an example of developer defined column as int[] array type.
int64Array [Int64] 🔨 int64Array is an example of developer defined column as bigint[] array type.
floatArray [Float] 🔨 floatArray is an example of developer defined column as double precision[] array type.
booleanArray [Boolean] 🔨 booleanArray is an example of developer defined column as boolean[] array type.
dateArray [Date] 🔨 dateArray is an example of developer defined column as date[] array type.
timestampArray [Timestamp] 🔨 timestampArray is an example of developer defined column as timestamptz[] array type.
anyArray [Any] 🔨 anyArray is an example of developer defined column as jsonb[] array type.
id UUID! ✨ Implicit primary key field. It's a UUID column default to a generated new value. See @table for how to customize it.
oneToOneExample_on_main OneToOneExample ✨ List OneToOneExample objects in a one-to-one relationship (where OneToOneExample.main is this object).
manyToManyJoinTables_on_right [ManyToManyJoinTable!]! ✨ List ManyToManyJoinTable objects in a one-to-many relationship (where ManyToManyJoinTable.right is this object).
manyToManyJoinTables_on_left [ManyToManyJoinTable!]! ✨ List ManyToManyJoinTable objects in a one-to-many relationship (where ManyToManyJoinTable.left is this object).
mainTables_via_ManyToManyJoinTable_on_left [MainTable!]! ✨ List MainTable objects using ManyToManyJoinTable as the join table (a ManyToManyJoinTable object exists where its right is this and its left is that).
mainTables_via_ManyToManyJoinTable_on_right [MainTable!]! ✨ List MainTable objects using ManyToManyJoinTable as the join table (a ManyToManyJoinTable object exists where its left is this and its right is that).
manyToOneExamples_on_main [ManyToOneExample!]! ✨ List ManyToOneExample objects in a one-to-many relationship (where ManyToOneExample.main is this object).

type ManyToManyJoinTable

🔨 ManyToManyJoinTable is an example of developer defined join table that establishes a many-to-many relationship between MainTable and itself.

type MainTable @table {
  someField: Any
}
type ManyToManyJoinTable @table(key: ["left", "right"]) {
  left: MainTable!
  right: MainTable!
}

NOTE: it's primary key are two columns with foreign key constraints to both sides of the many-to-many relationship. The primary key constraint ensures that for any given pair of MainTable rows, there is only one matching row in ManyToManyJoinTable.

Field Type Description
left MainTable! 🔨 left is an example of developer defined foriegn key constraint to the MainTable!. It's part of primary key columns pair of ManyToManyJoinTable.
right MainTable! 🔨 right is an example of developer defined foriegn key constraint to the MainTable!. It's part of primary key columns pair of ManyToManyJoinTable.
leftId UUID! ✨ Implicit foreign key field based on ManyToManyJoinTable.left. It must match the value of MainTable.id. See @ref for how to customize it.
rightId UUID! ✨ Implicit foreign key field based on ManyToManyJoinTable.right. It must match the value of MainTable.id. See @ref for how to customize it.

type ManyToOneExample

🔨 ManyToOneExample is an example of developer defined table type to demonstrates an one-to-many relationship between MainTable and ManyToOneExample.

type MainTable @table {
  someField: Any
}
type ManyToOneExample @table {
  main: MainTable!
  someField: Any
}
Field Type Description
main MainTable! 🔨 main is an example of developer defined foriegn key constraint to the MainTable!. Each row of ManyToOneExample has exactly one corresponding row in MainTable. Each row of MainTable can be associated with multiple rows in ManyToOneExample.
someField Any
id UUID! ✨ Implicit primary key field. It's a UUID column default to a generated new value. See @table for how to customize it.
mainId UUID! ✨ Implicit foreign key field based on ManyToOneExample.main. It must match the value of MainTable.id. See @ref for how to customize it.

type OneToOneExample

🔨 OneToOneExample is an example of developer defined table type to demonstrate an one-to-maybe relationship between MainTable and OneToOneExample.

type MainTable @table {
  someField: Any
}
type OneToOneExample @table {
  main: MainTable! @unique
  someField: Any
}
Field Type Description
main MainTable! 🔨 main is an example of developer defined foriegn key constraint to the MainTable!. The column also has a SQL unique constraint, which makes it a one-to-one relationship. Each row of OneToOneExample has exactly one corresponding row in MainTable. Each row of MainTable can be associated with one or none row in OneToOneExample.
someField Any
id UUID! ✨ Implicit primary key field. It's a UUID column default to a generated new value. See @table for how to customize it.
mainId UUID! ✨ Implicit foreign key field based on OneToOneExample.main. It must match the value of MainTable.id. See @ref for how to customize it.

type StringTable

🔨 StringTable is an example of developer defined table type to demonstrate array and non-null columns in a Postgres table.

type StringTable @table {
  stringField: String
  nonNullStringField: String!
  stringArray: [String]
  nonNullStringArray: [String!]
  stringNonnullArray: [String]!
  nonNullStringNonnullArray: [String!]!
}
Field Type Description
stringField String 🔨 stringField is an example of developer defined column as text type.
nonNullStringField String! 🔨 nonNullStringField is an example of developer defined column as text type. Since it cannot be null, Data Connect automatically adds a NOT NULL constraint to the column.
stringArray [String] 🔨 stringArray is an example of developer defined column as text[] array type. Data Connect doesn't support sparse array. Backend drops any null elements in the array before returning the result. stringArray and nonNullStringArray are equivalent.
nonNullStringArray [String!] 🔨 nonNullStringArray is an example of developer defined column as text[] array type. Data Connect doesn't support sparse array. Backend drops any null elements in the array before returning the result. stringArray and nonNullStringArray are equivalent.
stringNonnullArray [String]! 🔨 nonNullStringNonnullArray is an example of developer defined column as text[] array type. Since it cannot be null, Data Connect automatically adds a NOT NULL constraint to the column. Data Connect doesn't support sparse array. Backend drops any null elements in the array before returning the result. stringNonnullArray and nonNullStringNonnullArray are equivalent.
nonNullStringNonnullArray [String!]! 🔨 nonNullStringNonnullArray is an example of developer defined column as text[] array type. Since it cannot be null, Data Connect automatically adds a NOT NULL constraint to the column. Data Connect doesn't support sparse array. Backend drops any null elements in the array before returning the result. stringNonnullArray and nonNullStringNonnullArray are equivalent.
id UUID! ✨ Implicit primary key field. It's a UUID column default to a generated new value. See @table for how to customize it.

Built In

type __Directive

A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.

In some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.

Field Type Description
name String!
description String
locations [__DirectiveLocation!]!
args [__InputValue!]!
isRepeatable Boolean!

type __EnumValue

One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.

Field Type Description
name String!
description String
isDeprecated Boolean!
deprecationReason String

type __Field

Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.

Field Type Description
name String!
description String
args [__InputValue!]!
type __Type!
isDeprecated Boolean!
deprecationReason String

type __InputValue

Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.

Field Type Description
name String!
description String
type __Type!
defaultValue String A GraphQL-formatted string representing the default value for this input value.
isDeprecated Boolean!
deprecationReason String

type __Schema

A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.

Field Type Description
description String
types [__Type!]! A list of all types supported by this server.
queryType __Type! The type that query operations will be rooted at.
mutationType __Type If this server supports mutation, the type that mutation operations will be rooted at.
subscriptionType __Type If this server support subscription, the type that subscription operations will be rooted at.
directives [__Directive!]! A list of all directives supported by this server.

type __Type

The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the __TypeKind enum.

Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional specifiedByURL, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.

Field Type Description
kind __TypeKind!
name String
description String
fields [__Field!]
interfaces [__Type!]
possibleTypes [__Type!]
enumValues [__EnumValue!]
inputFields [__InputValue!]
ofType __Type
specifiedByURL String