Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akramsaouri/graf-it
Generate a mock GraphQL API without writing a single line of code.
https://github.com/akramsaouri/graf-it
graphql nodejs
Last synced: 3 months ago
JSON representation
Generate a mock GraphQL API without writing a single line of code.
- Host: GitHub
- URL: https://github.com/akramsaouri/graf-it
- Owner: akramsaouri
- Created: 2017-10-12T22:42:34.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T20:30:10.000Z (almost 2 years ago)
- Last Synced: 2024-06-17T19:59:54.800Z (5 months ago)
- Topics: graphql, nodejs
- Language: JavaScript
- Homepage:
- Size: 564 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-morocco - Graf-it - it.svg?style=social)](https://github.com/akramsaouri/graf-it/stargazers) - Generate a mock GraphQL API without writing a single line of code. (Uncategorized / Uncategorized)
README
# graf-it
## Install
`npm install -g graf-it`graf-it allows you to quickly generate a mock GraphQL API without writing a single line of code, good for quick prototyping and u know...stuff.
## Example
Create a `db.json` file:
```
{
"todos": [
{ "id": 4, "completed": false, "text": "Get some sleep" }
],
"users": [
{ "id": 6, "email": "[email protected]", "password": "secretcat" }
]
}
```Start GraphQL Server:
`$ graf-it db.json`
Tada! You now have a GraphiQL server starting at your http://localhost:3000/graphql where you can query and mutate models for this db.
## Queries and Mutations
Based on the previous `db.json` file, here are all the generated queries and mutations:
```
# queries
allTodos: [Todo]!
Todo(id: Int): Todo
allUsers: [User]!
User(id: Int): User# mutations
createTodo(id: Int, completed: Boolean!, text: String!): Todo!
updateTodo(id: Int!, completed: Boolean, text: String): Todo
deleteTodo(id: Int):Boolean!
createUser(id: Int, email: Boolean!, password: String!): User!
updateUser(id: Int!, email: Boolean, password: String): User
deleteUser(id: Int):Boolean!
```## Custom port
You can specify another port using the `--port` flag:
`$ graf-it db.json --port 9000`
## TODO
- Fix a bug where .00 Float are considered Int.