Floyd is a framework for building GraphQL backends, with first-class support for Typescript.
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.
You won't have to spend time searching and downloading packages and then setting them up just so you can get started. Floyd will do all that for you so you can hit the ground running and start writing your application logic.
Floyd will split your application code into separate components so that the logic remains easy to understand and maintain.
Use GraphQL Playground to test your API in development environment. You won't need to install and config any client just to explore your API.
npm install -g floyd-cli
or using Yarn:
yarn global add floyd-cli
floyd create <name> <path>
floyd create hello-world ~/playground
will create your project in
Learn more about the command here
npm run build
Now that you have compiled your code, you can simply run it, like so:
localhost:3000/graphql in your browser to test your GraphQL API using GraphQL Playground. It will look like this:
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.
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. Learn 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 database schema and export the model object.
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.
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.
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.
For a guide on how to contribute to this project, click here.