DEV Community

Cover image for GraphQL Centaur CLI on Product Hunt
Tomek Poniatowicz
Tomek Poniatowicz

Posted on

GraphQL Centaur CLI on Product Hunt

Hello, fellow Devs!

We have just launched our new open-source product on Product Hunt.
This time it's a GraphQL Centaur CLI which basically allows to bootstrap backend applications build with GraphQL and generate basic functions like CRUD.

GraphQL Centaur is a CLI tool with a goal to provide seamless experience
creating GraphQL as a service. How does it work?

βœ… takes any given GraphQL schema as input
βœ… generates Mongo/Stucco-js database resolvers in TypeScript
βœ… allows you to customize them the way that suits your project

All that to make the process of creating your GraphQL based backend more enjoyable!

Upvote on Product Hunt

I would like to ask you to share your thoughts about it & would appreciate any form of support like feedback or up-votes. We know that there is still a lot of space for the improvements for GraphQL Centaur! Thank you!

GraphQL Centaur CLI

Resolver generation

First time when you generate a resolver centaur will also generate needed libraries for collections, DB, Utils and graphql-zeus definitions, then given the following schema:

type Person{
    firstName: String!
}
type Query{
    people: [Person]!
}
schema{
    query: Query
}
Enter fullscreen mode Exit fullscreen mode

after choosing the following elements:

  • Query
  • people
  • CRUD
  • listFilter

GraphQL Centaur should generate TypeScript resolver placed in $src/Query/people.ts directory:

import { FieldResolveInput, FieldResolveOutput } from "stucco-js";
import { PersonCollection } from "../db/collections";
import { DB } from "../db/mongo";
import { Utils } from "../Utils";
import { Person, ResolverType, ValueTypes } from "../graphql-zeus";

export const handler = async (): Promise<FieldResolveOutput> => {
    const db = await DB();
    const col = await db.collection(PersonCollection);
    return Utils.CursorToGraphQLArray<Person>(
        await col.find({}),
    );
};
Enter fullscreen mode Exit fullscreen mode

Upvote on Product Hunt

Thank you!

Top comments (0)