graphql - Connection is based on `array`,is this a design style guide for design a relay server? -


in connection/arrayconnection.js, seems function tend work array.
example: offsettocursor way generate cursor. mean design pattern must follow, or imply should generate cursor myself when using other array.if im planning use mongodb,should make database interface static array ?

btw:
newbie web develop, im bit confused how implement qualified relay server.
there guide design graphql-relay server, should follow way in graphql-relay-js, database facebook used relay-server ? mysql or ?
im not sure ask here appropriate or not,but topic graphql-relay-js on web.
lot, forgive impolite.

var prefix = 'arrayconnection:'; /**  * creates cursor string offset. */ export function offsettocursor(offset: number): connectioncursor {     return base64(prefix + offset); } 

additional question:
maybe idea developers.facebook.com/docs/graph-api.
seems should array style cache pagination lookup( not sure this). graph-api looks bit different graphql-relay-js (is graph-api still part of old restful style?),
relationship between graph-api , graphql-relay-js ? graphql-relay-js common design guide design graphql server in facebook? lot! please give me hints

connection design pattern schema may implement if want relay perform efficient pagination. how gets implemented on backend implementation detail. may backed array-like, or may not (think infinite scrolling news feed on facebook, ranked terribly sophisticated backend service: not backed array). provide arrayconnection.js module way of demonstrating how can done if data source has array-like nature. if not, or cannot efficiently converted it, better off implementing scratch.

cursors opaque identifiers. use array index or kind of primary key if using array source or typical database backend (like mysql), again details implementation-specific , should chosen suit end. requirement cursor should encode whatever information need on server able return next page of results after (or before) point.

graphql-relay-js collection of modules provide helpers building relay-compatible graphql schemas in javascript. schema provides uniform interface data, actual underlying storage can want plug (a mysql database, object in memory, rest service). simple examples, in the examples directory in relay repo. illustration of how can put schema in front of not traditional database, this example of schema reads data out of git repo, of indices in redis , cached data in memcached.

stay away developers.facebook.com/docs/graph-api; despite "graph" in name entirely different thing , has nothing graphql hierarchical query language relay uses.


Comments