Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Extras/TODOs.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,21 @@ using Python and FastAPI
- [x] Update the test fixture @generateUDID
- [x] Endpoint to renew access token
- [x] Improve integration coverage (current is 85% - mostly HTTPExceptions are not covered)
- [ ] Reqover coverage

## October
- [x] Publish about this project in LinkedIn and in my blog.
- [ ] Generate total time spent for this project from README.md


## Jan 2024
- [ ] Reqover coverage
- [ ] /graphql endpoint
- [ ] Database backup using pg_dump and pg_restore
- [ ] Jenkins pipeline
- [ ] Add release notes
- [ ] Maintain release version numbers
- [ ] Head, Options, Patch and Trace
- [ ] Explore ruff package****


## Later
## Q1 2024
- [ ] Host it in cloud
- [ ] Tracking and limiting usage
- [ ] Monitoring
Expand All @@ -74,6 +75,8 @@ using Python and FastAPI
- [ ] Explore Fire
- [ ] Explore query builder
- [ ] Create admin API - to activate, de-active, delete users.
- [ ] Generate total time spent for this project from README.md



### Action items
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ This app uses a JSON to store data.

## WHAT NEXT?

### 2023 Q4
### 2024 Q1
- Admin endpoints to manage users, roles and data
- Head, Options, Patch and Trace endpoints
- JS GraphQL endpoint
Expand Down
14 changes: 12 additions & 2 deletions graphql/src/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "4",
"title": "Learn Python",
"description": "Updating description.",
"doneStatus": false
"doneStatus": true
},
{
"id": "4327839b-1952-42c8-8936-5f56402a2976",
Expand Down Expand Up @@ -60,7 +60,7 @@
},
{
"id": "2b647661-99e2-47a2-9e1c-e4c311505e37",
"title": "This is checking",
"title": "This is updated again and again.",
"doneStatus": false,
"description": "Updating description."
},
Expand All @@ -74,5 +74,15 @@
"id": "48aecea2-c3aa-4a77-ba78-1f858705c8e3",
"title": "This is adding new",
"doneStatus": true
},
{
"id": "f0c486b7-8315-49b9-b28d-37a2f3f8dc4a",
"title": "This is adding new",
"doneStatus": false
},
{
"id": "b7c321d0-95e3-417a-b0ef-6a1df99b8dfa",
"title": "This is testing again.",
"doneStatus": false
}
]
5 changes: 3 additions & 2 deletions graphql/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import fs from 'fs';

import { createServer } from 'http'
import { createYoga, createSchema, createPubSub } from 'graphql-yoga'
import { createYoga, createSchema } from 'graphql-yoga'
import { PubSub } from 'graphql-subscriptions';
import Query from './resolvers/Query.js';
import Mutation from './resolvers/Mutation.js';
import Subscription from './resolvers/Subscription.js';
import db from './db.js';

const pubsub = createPubSub();
const pubsub = new PubSub();

const schemaFile = 'src/schema.graphql';
const typeDefs = fs.readFileSync(schemaFile, 'utf8');
Expand Down
2 changes: 1 addition & 1 deletion graphql/src/resolvers/Mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Mutation = {
todo.doneStatus = data.doneStatus
}
saveJson(filepath, db.todos);
pubsub.publish(`todo ${id}`, { todo })
pubsub.publish(`todoUpdates ${id}`, { todoupdates: todo })
return todo
},

Expand Down
25 changes: 12 additions & 13 deletions graphql/src/resolvers/Subscription.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
const Subscription = {
// todoUpdates:{
// subscribe: (parent, { todoID }, { pubsub }, info) =>
// pubsub.subscribe(`todoUpdates_${todoID}`)
// },
todoUpdates:{
subscribe: (parent, { todoID }, { db, pubsub }, info) => {
console.log(pubsub)
const todo = db.todos.find(todo => todo.id === todoID)
if (!todo) {
throw new Error(`No todo with id ${todoID}`)
}
return pubsub.asyncIterator(`todoUpdates ${todoID}`)
},
countdown:{
subscribe: async function* (_, { from }) {
subscribe: async function* (parent, { from }, { pubsub }, info) {
for (let i = from; i >= 0; i--) {
await new Promise(resolve => setTimeout(resolve, 1000))
yield { countdown: i }
}
}
}

// countdown:{
// subscribe: (parent, args, { pubsub }, info) => {
// // console.log(args.from);
// let count = 0;
// setInterval(() => pubsub.publish('countdown', { count: count++ }), 1000);
// return pubsub.subscribe('countdown');
// }
// }
}
}

export { Subscription as default };