Declarative API

This is the reference for the declarative API parts of the library. See also Background: GraphQL Injections.

i18n(key, args)

Returns a translation of the given translation key with additional optional arguments

Parameters

NameTypeDescription
keystringtranslation tag/key
args... stringoptional translation parameters

injection(query, defaultVars)

Declares a GraphQL injection that will be automatically provided to the process scope on process initialization. The returned value is a query declaration object that is used to resolve the data from the initial process data provided by the server. The server in turn uses JSON data generated by NPM module "babel-plugin-track-usage" to automatically determine the injection queries. The GraphQL query value will be stripped of its first level. There can be only one query or mutation per injection. This has no performance implications since all initial process queries are running at once on the server side anyway.

Parameters

NameTypeDescription
query------query string
defaultVars------Formal variable parameter. Not really used on the client side per se. Only needed to be detected by NPM module "babel-plugin-track-usage"

query(query)

Creates a GraphQL query with the given query string and default variables. This static version can be tracked by babel-plugin-track-usage and is used to declare named queries.

Parameters

NameTypeDescription
queryStringquery String