In the newest version of Nodal, we're pleased to announce the first steps in our GraphQL implementation. We're a bit limited in scope and don't yet support the full specification (only parts of queries), but we're really excited to offer a fully-integrated developer-friendly GraphQL solution, built atop PostgreSQL. We think GraphQL represents a great step forward for service-oriented architectures, providing front-end developers more effective control over the data they retrieve.
For the GitHub repo running this example, check out keithwhor/nodal-graphql.
If you're curious about what this is built with: we've built our own GraphQL syntax parser, have it translate the syntax tree into a format Nodal's Composer (ORM) is familiar with, and then generate queries from there. Our data layer is entirely PostgreSQL, and each call to the database exists as a single query with multiple joins.
We welcome you to play with our GraphQL endpoint. We have a sample of 3 users, 9 threads and 27 posts for you to query.
There are three models:
- User (users): id, email, age, created_at, updated_at, threads, posts
- Thread (threads): id, title, created_at, updated_at, user, posts
- Post (posts): id, body, created_at, updated_at, user, thread
And a number of operators:
- is, not, lt, lte, gt, gte, contains, icontains, startswith, endswith, iendswith, like, ilike
module.exports = (function() {
'use strict';
const Nodal = require('nodal');
const GraphQuery = Nodal.GraphQuery;
class GraphController extends Nodal.Controller {
post() {
let str = this.params.buffer.toString();
GraphQuery.query(str, 5, (err, models, format) => {
this.respond(err || models, format);
});
}
}
return GraphController;
})();