Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

Remora

Simple GraphQl server with 3 line code.

Project structure

your_remora_project/
β”œβ”€ server.ts
β”œβ”€ lambdas/
β”‚  β”œβ”€ ExampleLambda/
β”‚  β”‚  β”œβ”€ schema.gql <-- GraphQL schema
β”‚  β”‚  β”œβ”€ query.ts <---- Query function here (optional)
β”‚  β”‚  β”œβ”€ mutation.ts <- Mutation function here (optional)

server.ts

import { Remora } from 'https://deno.land/x/remora/mod.ts';
const server = new Remora("./lambdas"); // import your lambda directory
await server.listen();

schema.gql

type Query {
    getExample(id: Int!): Example
    getExamples(topic: String): [Example]
},

type Example {
    id: Int
    title: String
    author: String
    description: String
    topic: String
    url: String
}

query.ts

var coursesData = [
    {
        id: 1,
        title: 'The Complete Node.js Developer Course',
        author: 'Andrew Mead, Rob Percival',
        description: 'Learn Node.js by building real-world applications with Node, Express, MongoDB, Mocha, and more!',
        topic: 'Node.js',
        url: 'https://codingthesmartway.com/courses/nodejs/'
    },
    {
        id: 2,
        title: 'Node.js, Express & MongoDB Dev to Deployment',
        author: 'Brad Traversy',
        description: 'Learn by example building & deploying real-world Node.js applications from absolute scratch',
        topic: 'Node.js',
        url: 'https://codingthesmartway.com/courses/nodejs-express-mongodb/'
    },
    {
        id: 3,
        title: 'JavaScript: Understanding The Weird Parts',
        author: 'Anthony Alicea',
        description: 'An advanced JavaScript course for everyone! Scope, closures, prototypes, this, build your own framework, and more.',
        topic: 'JavaScript',
        url: 'https://codingthesmartway.com/courses/understand-javascript/'
    }
]

export function getExample(args) {
    var id = args.id;
    return coursesData.filter(course => {
        return course.id == id;
    })[0];
}

export function getExamples(args) {
    if (args.topic) {
        var topic = args.topic;
        return coursesData.filter(course => course.topic === topic);
    } else {
        return coursesData;
    }
}