floyd-framework / Cli
Programming Languages
Projects that are alternatives of or similar to Cli
Floyd
The famework for building GraphQL backends, with first-class support for Typescript. You won't need to spend time trying to set up the GraphQL backend, Floyd will do it for you.
Why
REST APIs are cumbersome to build and even tougher to deal with (for frontend developers). GraphQL eliminates most of the problems developers face while building and using APIs. See more benefits of GraphQL here.
Concepts
Floyd only has a few concepts you need to understand to get up and running with it. It is made to be as simple as possible to pick up and use.
Components
A Floyd app is divided into multiple components, with each component having its own Schema, Resolvers and Model.
- Schema: It is a GraphQL schema with its own queries, mutations and subscriptions. Learn more here
- Resolvers: These are the functions you write in code that map to the queries, mutations and subscriptions you have defined. Lern more here
- Model: This is your Database model for your component. It is the M in MVC. In this file, you specify your model's databse schema and export the model object.
Typescript
One of the advantages of GraphQL over REST is you can know beforehand exactly what the type and structure of the result will be. We wanted to extend this feature into all your app's code and hence we chose Typescript. Typescript helps you avoid a lot of the errors that might encounter during runtime in Javascript simply because you used the wrong type of object or didn't know what members the object has. Learn more here.
Getting started
Install the Floyd CLI
with npm:
npm install -g floyd-cli
Or using Yarn:
yarn global add floyd-cli
create
command:
Create your project in any directory you want using the floyd create <name> <path>
For example:
floyd create hello-world ~/playground
will create your project in ~/playground/hello-world/
Learn more about the command here
add
command:
Add a component to your project using the Make sure you are inside your project's directory, then to add a component named cat
:
floyd add cat
It will create a folder cat in your components folder as shown in the project structure below.
Learn more about the command here
Project structure
Floyd has a simple and recognisable project structure so when you pick up someone else's Floyd app to maintain or contribute to, you feel right at home.
.
โโโ app
โ โโโ app.config.json
โ โโโ components
โ โ โโโ cat
โ โ โโโ model.ts
โ โ โโโ resolvers.ts
โ โ โโโ schema.graphql
โ โโโ db.ts
โ โโโ helpers.ts
โ โโโ index.ts
โ โโโ resolvers.ts
โ โโโ schema.graphql
โโโ LICENSE
โโโ package.json
โโโ package-lock.json
โโโ README.md
โโโ tsconfig.json
The app folder will contain all the code for your backend.
-
app.config.json
will contain all your configuration options, like database URL, name of all the components, etc. - The
components
folder will contain all your components, each in its separate folder by name. -
schema.graphql
will contain the global types of your schema, i.e. types needed by more than one component's schema. - Similarly,
resolvers.ts
will contain all the global resolvers that you might need, just make sure none (neither global nor component specific) of your resolver names collide, since all of them will be made available in the same scope.
Contributing
For a guide on how to contribute to this project, click here.