0.1.3 • Published 5 years ago

floyd-cli v0.1.3

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Floyd

Join the chat at https://gitter.im/floyd-framework/cli

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 your project in any directory you want using the create command:

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 a component to your project using the add command:

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.

Code of Conduct

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

1.0.0

5 years ago