Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: graphql endpoints, queries and mutations #71

Merged
merged 35 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
122a351
refactor: modules and graphql servers
froid1911 Feb 5, 2024
07131ae
refactor: graphql queries and mutations for different endpoints
froid1911 Feb 5, 2024
01b3017
chore: changed graphql paths for drives and drive
froid1911 Feb 6, 2024
a8c49c8
chore: added server and drive system queries and reorganized object t…
froid1911 Feb 6, 2024
3f21b37
Merge branch 'main' into feat/newGraphQLSchema
froid1911 Feb 6, 2024
c8ed5c9
chore: added default value for skip parameter
froid1911 Feb 6, 2024
3aa065e
chore: move strands to sync object
froid1911 Feb 6, 2024
bfaede2
feat: added document and rwa modules and interfaces
froid1911 Feb 7, 2024
687b447
feat: added rwa graphql objects definitions
froid1911 Feb 7, 2024
df0c032
chore: added getDocument to document model
froid1911 Feb 7, 2024
d1bfd07
chore: bump document drive and lib versions
froid1911 Feb 8, 2024
7d3adaf
refactor: document drive module
froid1911 Feb 8, 2024
e7d9943
chore: changed transactionType to string
froid1911 Feb 8, 2024
a6bb4a7
chore: added ID to document interface
froid1911 Feb 8, 2024
7f3f3f6
chore: renamed to core-unit
froid1911 Feb 8, 2024
61bb1f6
chore: added rwa state to rwa document
froid1911 Feb 8, 2024
34c638f
feat: added real world assets portfolio query
froid1911 Feb 8, 2024
7d3a538
chore: cleanup
froid1911 Feb 9, 2024
99be05f
refactor: cleanup document drive module
froid1911 Feb 9, 2024
88210c8
chore: wording and housekeeping of document interface
froid1911 Feb 9, 2024
77bf82c
chore: removed mock data
froid1911 Feb 9, 2024
4e6695f
feat: added budget statement document
froid1911 Feb 9, 2024
3ec7874
feat: added scope framework
froid1911 Feb 9, 2024
1c83ad4
feat: added account snapshot document
froid1911 Feb 9, 2024
3089d08
chore: updated document type resolver to use name
froid1911 Feb 9, 2024
2950846
chore: updated name of rwa document
froid1911 Feb 9, 2024
61c55d6
feat: added scalar attachment
froid1911 Feb 9, 2024
c51b335
chore: activated new document models
froid1911 Feb 9, 2024
5716ca6
Updated transmitters response
acaldas Feb 12, 2024
91a0981
test: fix existing tests
froid1911 Feb 12, 2024
e1dce1c
chore: bump document drive version
froid1911 Feb 12, 2024
2b9faaa
chore: updated document drive tests
froid1911 Feb 12, 2024
947508c
chore: removed old files
froid1911 Feb 12, 2024
7abdb8e
test: work on document drive tests
froid1911 Feb 12, 2024
4e2d6ca
test: fixed document drive test
froid1911 Feb 13, 2024
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
1,802 changes: 274 additions & 1,528 deletions api/package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,29 @@
},
"dependencies": {
"@apollo/server": "^4.5.0",
"@prisma/client": "^5.7.1",
"@prisma/client": "5.7.1",
"@types/cookie-parser": "^1.4.3",
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"document-drive": "powerhouse-inc/document-drive#ec00335",
"document-drive": "powerhouse-inc/document-drive#11548bc",
"document-model": "^1.0.24",
"document-model-libs": "^1.1.37",
"document-model-libs": "1.1.42",
"dotenv": "^16.0.3",
"ethers": "^5.7.2",
"express": "^4.18.2",
"graphql": "^16.7.1",
"graphql-middleware": "^6.1.33",
"graphql-playground-middleware-express": "^1.7.23",
"json-stringify-deterministic": "^1.0.12",
"jsonwebtoken": "^9.0.0",
"module-example": "file:../module-example",
"ms": "^2.1.3",
"nexus": "^1.3.0",
"nexus-validation-plugin": "^0.2.0",
"pino": "^8.11.0",
"pino-http": "^8.3.3",
"pino-pretty": "^10.0.0",
"module-example": "file:../module-example",
"siwe": "^2.1.4",
"vite-node": "^0.29.2",
"vitest": "^0.31.1",
Expand All @@ -60,7 +61,7 @@
"gql-query-builder": "^3.8.0",
"graphql-request": "^5.2.0",
"node-fetch": "^3.3.1",
"prisma": "^5.7.1",
"prisma": "5.7.1",
"typescript": "^4.9.5",
"vitest-mock-extended": "^1.1.3"
}
Expand Down
37 changes: 18 additions & 19 deletions api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,35 @@ model Challenge {

// Document Drive
model Document {
id String
driveId String
created DateTime @default(now())
lastModified DateTime @default(now())
revision Json
name String?
operations Operation[]
initialState Json // json object with the scope as keys of the root object
documentType String
id String
driveId String
created DateTime @default(now())
lastModified DateTime @default(now())
revision Json
name String?
operations Operation[]
initialState Json // json object with the scope as keys of the root object
documentType String
syncronizationUnits SyncronizationUnit[]

@@id([id, driveId])
}

model Operation {
driveId String
Document Document? @relation(fields: [driveId, documentId], references: [driveId, id], onDelete: Cascade)
documentId String
scope String
branch String
index Int
skip Int

driveId String
Document Document? @relation(fields: [driveId, documentId], references: [driveId, id])
documentId String
scope String
branch String
index Int
skip Int
hash String
timestamp DateTime
input Json
type String
attachments Attachment[]

syncId String?
syncId String?
clipboard Boolean? @default(false)

SyncronizationUnit SyncronizationUnit? @relation(fields: [syncId, driveId], references: [id, driveId])

Expand Down
29 changes: 14 additions & 15 deletions api/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import type { Express } from "express";
import express from "express";
import expressPlayground from "graphql-playground-middleware-express";
import { getChildLogger } from "./logger";
import basePrisma from "./database";
import { API_GQL_ENDPOINT } from "./env";
import type { Express } from 'express';
import express from 'express';
import expressPlayground from 'graphql-playground-middleware-express';
import { getChildLogger } from './logger';
import basePrisma from './database';
import { API_GQL_ENDPOINT } from './env';

const logger = getChildLogger({ msgPrefix: "APP" });
const logger = getChildLogger({ msgPrefix: 'APP' });
const startupTime = new Date();

export const createApp = (): Express => {
logger.debug("Creating app");
logger.debug('Creating app');
const app = express();

app.get("/healthz", async (_req, res) => {
app.get('/healthz', async (_req, res) => {
try {
// TODO: after migration to postgres, do SELECT 1
await basePrisma.user.findFirst();
} catch (error: any) {
return res.status(500).json({
Expand All @@ -24,21 +23,21 @@ export const createApp = (): Express => {
});
}
return res.json({
status: "healthy",
status: 'healthy',
time: new Date(),
startupTime,
});
});

app.get(
"/",
'/',
expressPlayground({
endpoint: API_GQL_ENDPOINT,
settings: {
"editor.theme": "light",
"request.credentials": "include",
'editor.theme': 'light',
'request.credentials': 'include',
},
})
}),
);

return app;
Expand Down
2 changes: 1 addition & 1 deletion api/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PrismaClient, Prisma } from '@prisma/client';
import { Level as PinoLevel } from 'pino';
import { getChildLogger } from './logger';
import { getUserCrud, getSessionCrud, getChallengeCrud } from './modules';
import { getDocumentDriveCRUD } from './modules/DocumentDrive';
import { getDocumentDriveCRUD } from './modules/document';

const dbLogger = getChildLogger({ msgPrefix: 'DATABASE' });

Expand Down
48 changes: 0 additions & 48 deletions api/src/graphql/context.ts

This file was deleted.

16 changes: 0 additions & 16 deletions api/src/graphql/dateSchema.ts

This file was deleted.

Loading