1.1.0 • Published 6 years ago

graphql-file-server v1.1.0

Weekly downloads
69
License
DBaJ
Repository
-
Last release
6 years ago

GraphQL File Server

Install

npm install -g graphql-file-server

GFS (short for GraphQL File Server) 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": "Learn something" }
    ],
    "users": [
        { "id": 6, "email": "cat@mail.com", "password": "secretcat" }
    ]
}

Start GraphQL Server:

$ gfs 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:

$ gfs db.json --port 9000

Room for improvements

  • Use lowdb instead of fs to persist mutations on db.
  • Refactor code for index collection.
  • Fix a bug where .00 Float are considered Int.
  • Fly to mars.
1.1.0

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago