OpO FAST Triple Store, Web Server, and JSON Database
OpO

OpO is a database for storing JSON as triples. There are two ways to retrieve data, one is getting a JSON record using the record ID. The other is with a query what includes parameters such as a WHERE clause, a FILTER, or a LIMIT. OpO provides a set of options for defining the GraphQL API that are composed of thos primitives.

At first glance it would seem that providing a generic get() and a find() function would be sufficient but GraphQL takes a strongly typed approach to queries. The contents of the returned JSON can not be specified without knowing the type of the returned object. To satisfy that need by GraphQL APIs patterns are used. A function defined in an SDL file that starts with get followed by a GraphQL type is an indication that a generic get() should be used but with a return type as indicated. A simlar approach is taken with find() functions. Finally the GraphQL @directive can be used to defined a function with any name.

get<Type>(id: ID!)

The arguments to a get<Type>() must be a single argument named id and it must have a type of ID!. The return type must match the latter part of the function name.

The id argument identifies a specific JSON node. If not found an error is returned.

SDL

type Query { getUser(id: ID!): User }
find<Type>(where: String, filter: String, limit: Int, sort: [String!], cursor: String)

The find<Type>() function is similar to the OpO SELECT. The return type must match the latter part of the function name as a list.

The where and where arguments are strings that follows the friendly TQL format.

The limit argument specifies the maximum number of records to return.

The sort argument lists the paths into the record to be used as sort criteria. A - preceeding the path indicates a reverse order sort.

The cursor argument identifies the name of a previous query as well as the offset into that result set. Usually this is used with the limit argument to return a page of records.

SDL

type Query { findUser(where: String, filter: String, limit: Int, sort: [String!], cursor: String): [User] }
@OpO(where: String, filter: String, limit: Int, sort: [String!])

GraphQL has @directives that can be used to provide hints to the application, OpO in this case. The OpO directive can be used with any function on the Query type to define the functions behavior. The function can no arguments or it can have some subset of the find arguments which will be used to replace the defaults provided in the directive.

SDL

type Query { myFunction(): [User] @OpO(where: "EQ(kind 'User')") }