Relatude Help

33.3 The schema

Every exposed node type gets a GraphQL type and two root fields on Query:

  • one that fetches a node by id, such as event(id: ID!);
  • one that returns a page of nodes, such as events(filter, search, orderBy, descending, page, pageSize, ids).

Every node type implements the Node interface and its four system fields: id (the node's Guid), displayName, createdUtc and changedUtc. Here is the schema of the endpoint above, trimmed:

type Query {
  event(id: ID!): Event
  events(filter: EventFilterInput, search: String, orderBy: EventOrderBy, descending: Boolean = false,
         page: Int = 0, pageSize: Int, ids: [ID!]): EventResult!
  venue(id: ID!): Venue
  venues(filter: VenueFilterInput, search: String, orderBy: VenueOrderBy, descending: Boolean = false,
         page: Int = 0, pageSize: Int, ids: [ID!]): VenueResult!
  upcoming(filter: EventFilterInput, search: String, orderBy: EventOrderBy, descending: Boolean = false,
           page: Int = 0, pageSize: Int, ids: [ID!]): EventResult!
}

interface Event implements Node {
  id: ID!
  displayName: String
  createdUtc: DateTime!
  changedUtc: DateTime!
  price: Decimal!
  starts: DateTime!
  status: EventStatus!
  title: String
  venue: Venue
}

type EventNode implements Node & Event { ... }   # the same fields

interface Venue implements Node {
  ...
  capacity: Int!
  events(top: Int): [Event!]!
  location: GeoCoordinate
  name: String
}

type EventResult {
  items: [Event!]!
  totalCount: Int!
  pageIndex: Int!
  pageSize: Int
  durationMs: Float!
}

enum EventOrderBy { price starts status title }
enum EventStatus { Draft Published SoldOut Cancelled }

input EventFilterInput {
  price: DecimalFilterInput
  starts: DateTimeFilterInput
  status: EventStatusFilterInput
  title: StringFilterInput
  venue: RelatedNodeFilterInput
  and: [EventFilterInput!]
  or: [EventFilterInput!]
  not: EventFilterInput
}

Names. By default, names follow GraphQL conventions. With exactNames, the datamodel's names are used as they are:

Default With exactNames
Type Article Article
Field title Title
Root fields article, articles Article, Articles
Mutations createArticle, … CreateArticle, …
  • System fields keep their names. A property that would clash with one gets Value added: DisplayName becomes displayNameValue.
  • A name that is taken gets _2 added, with a warning.
  • An inherited property keeps the field name its base type gives it. A different name set on the subtype is ignored, with a warning.

Interfaces. A datamodel interface becomes a GraphQL interface, plus an object type for the nodes created as that interface (db.Create<IEvent>()), since GraphQL values cannot have an interface type. The object type drops the leading I (IEvent gives Event), or adds Node when it cannot (Event gives EventNode). Queries use the interface name; __typename returns the object type.

A class with exposed subclasses also gets an interface, <Class>Interface, so a field of the class's type can return subclass nodes. Read a subclass's own fields with ... on Subclass { }. A node of a type the endpoint does not expose is shown as its nearest exposed ancestor.

How properties map:

Datamodel property GraphQL field filter operators In orderBy Mutation input
bool Boolean! eq ne yes Boolean
int Int! eq ne gt gte lt lte in nin yes Int
enum (int with an enum type) the enum, by name eq ne in nin yes the enum
long Long! as int yes Long
double, float Float! as int yes Float
decimal Decimal! as int yes Decimal
string String eq ne in nin yes String
DateTime, DateTimeOffset DateTime!, an ISO-8601 UTC string eq ne gt gte lt lte yes DateTime
TimeSpan String! – – String, such as "01:30:00"
Guid ID! eq ne in nin – ID
string[], Guid[], enum [] [String!]!, [ID!]!, [Enum!]! – – a list
GeoCoordinate GeoCoordinate { latitude longitude }, null when unset – – GeoCoordinateInput
FileValue FileInfo { name size width height contentType url }, null when empty – – –
relation, "one" side the related type eq in (by id) – ID
relation, "many" side [T!]! with a top argument eq in (by id) – [ID!], which replaces the whole set
Reference<T> T eq in (by id) – ID
References<T> [T!]! with a top argument – – [ID!]
Embedded, EmbeddedMap, byte[], float[], object left out

A relation or reference to a type the endpoint does not expose is left out, with a warning in the Selected mode. Its filter stays, since it takes only an id.