koa-server
GraphQL Back-end Server with Relay, Koa, MongoDB and Mongoose
NOTE: See Front-end project graphql-relay-web
Stack
- Koa
- MongoDB
- Mongoose
- GraphQL
- Relay
- Jest
- SuperTest
- Code Coverage(Codecov) see
Project architecture
.
โโโ graphql/
โ โโโ schema.graphql
โโโ script
โโโ src/
โ โโโ __tests__
โ โโโ database
โ โโโ graphql
โ โโโ modules/
โ โ โโโ event/
โ โ โ โโโ __tests__
โ โ โ โโโ fixure
โ โ โ โโโ mutations/
โ โ โ โ โโโ __tests__
โ โ โ โ โโโ EventCreateMutation.ts
โ โ โ โ โโโ EventDeleteMutation.ts
โ โ โ โ โโโ EventUpdateMutation.ts
โ โ โ โ โโโ index.ts
โ โ โ โโโ EventFilterInputType.ts
โ โ โ โโโ EventLoader.ts
โ โ โ โโโ EventModel.ts
โ โ โ โโโ EventType.ts
โ โ โโโ node/
โ โ โโโ typeRegister.ts
โ โโโ schema/
โ โ โโโ MutationType.ts
โ โ โโโ QueryType.ts
โ โ โโโ schema.ts
โ โโโ shared
โโโ test
Getting Started
- clone this repo
# install dependencies
yarn
# or
yarn install
# copy .env file
cp .env.example .env
# start project
yarn start
# see on GraphiQL graphql interface on localhost link
http://localhost:9000/graphql
# or see graphql Playground
http://localhost:9000/playground
Generating the schema
yarn schema
Create events manually
yarn seed
to-do
demo
Mutations
- Event Create Mutation
mutation {
EventCreate (input: {
eventId: 564654,
name: "nice event",
start: "2022-07-01T00:00:00.000Z",
end: "2022-07-01T23:59:59.000Z",
allDay: false
}) {
event {
id
name
start
end
allDay
}
error
success
}
}
- Event delete Mutation
mutation {
EventDelete (input: { eventId: "629521641ff2c2c8f5f2e449" }) {
eventId
error
success
}
}
- Event Update Mutation
mutation {
EventUpdate (input: {
eventId: "62952906f5c651ced019adf3",
name: "nice event /o/",
start: "2022-07-01T00:00:00.000Z",
end: "2022-07-01T23:59:59.000Z",
allDay: false
}) {
event {
id
name
start
end
allDay
}
error
success
}
}
Queries
- Event queries
query {
events {
edges {
node {
name
start
end
allDay
}
}
}
}
contributions
Feel free to contribute to this project, if you find any bugs or improvements, open an issue and send a PR about it \o/