Docs
Try GraphOS

Server-Driven UI Schema Patterns

schema-designserver-driven-ui

These patterns provide examples of server-driven ui and how you may structure your graph’s schema to encode and represent user-interface elements. A client would use a platform specific rendering engine to interpret the schema and generate interface components, for an example of a dynamic rendering client see TN32.

Device-based SDUI (with Enums)

Using a known device-type list can be useful in cases where a structured interface is provided through the graph on a per-device basis.

enum UIDeviceType {
MOBILE
WEB
ROKU
APPLETV
}
interface UIApp {}
type WebApp implements UIApp {}
type IOSApp implements UIApp {}
type AndroidApp implements UIApp {}
type AppleTVApp implements UIApp {}
type RokuApp implements UIApp {}
type Query {
app(type: UIDeviceType! = WEB): UIApp!
}

Device-based SDUI (with Contracts)

A similar device-based SDUI with Contracts could be used to remove interface components from the schema which are unrelated to the target platform.

type UIApp {
spotlight: UISpotlightComponent @tag(name: "DESKTOP")
dashboard: UIDashboardComponent
mobileMenu: UIMenuComponent @tag(name: "MOBILE")
menu: UIMenuComponent @tag(name: "WEB")
}
type Query {
app: UIApp!
}

SDUI Web Dashboard (static)

An example of a web application dashboard with a static structure encoded into the schema.

type AppLogo {
url: String
alt: String
}
type AppLink {
icon: String
label: String
path: String
}
type AppUserMenu {
user: User
}
type AppNavbar {
logo: AppLogo
items: [AppLink]
user: AppUserMenu
}
type AppMobileMenu {
items: [AppLink]
user: AppUserMenu
}
type AppHomePage {
recommended: [AppLink]
}
type WebApp {
navbar: AppNavbar
menu: AppMobileMenu
home: AppHomePage
settings: AppSettingsPage
profile: AppProfilePage
}
type Query {
app: WebApp!
}

SDUI Web Dashboard using Interfaces

This example uses interfaces to construct dynamic responses. Using this pattern the “experience” subgraph can dynamically return different interface components.

interface UIComponent {
id: ID
}
type UILogo implements UIComponent {
id: ID
url: String
alt: String
}
interface UINavbarItem implements UIComponent {
id: ID
label: String
path: String
icon: String
}
interface UINavbar implements UIComponent {
id: ID
logo: UILogo
items: [UINavbarItem]
}
interface UIMenuItem implements UIComponent {
id: ID
label: String
path: String
icon: String
}
interface UIMenu implements UIComponent {
id: ID
logo: UILogo
items: [UIMenuItem]
}
interface UISidebar implements UIComponent {
id: ID
title: String
content: [UIComponent]
}
interface UILayout implements UIComponent {
id: ID
content: [UIComponent]
}
interface UIScreen implements UIComponent {
id: ID
current: UIPage
navbar: UINavbar
menu: UIMenu
main: UILayout
sidebar: UISidebar
}
enum UIPage {
HOME
DASHBOARD
SETTINGS
}
type Query {
app(page: UIPage!): UIScreen!
}
Next
Home
ForumsDiscord