Relay uses routes to define entry points into a Relay application.
Note
Relay routes don't really implement any URL routing specific logic or work with History API. In the future we will maybe rename RelayRoute to be something more like RelayQueryRoots or RelayQueryConfig.
Properties
Methods
static paramDefinitions: {[param: string]: {required: boolean}}
Routes can declare a set of parameter names that it requires to be supplied to the constructor. This is also a convenient place to document the set of valid parameters.
class ProfileRoute extends Relay.Route { static paramDefinitions = { userID: {required: true}, }; // ... }
static queries: { [queryName: string]: () => Relay.QL`query { ... }` };
Routes must declare a set of query roots using Relay.QL
. These queries will automatically compose a matching fragment named queryName
on
the Relay container used with this route on a Relay.RootContainer.
class ProfileRoute extends Relay.Route { static queries = { user: () => Relay.QL`query { user(id: $userID) }`, }; // ... }
static routeName: string
Routes must define a string name.
Create a route instance using the new
keyword, optionally passing it some params.
var profileRoute = new ProfileRoute({userID: '123'});