Skip to content
This repository has been archived by the owner on Mar 22, 2019. It is now read-only.

Modularize schemas #224

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"scripts": {
"build": "babel src/ -d dist/ --copy-files",
"start": "node dist/",
"dev": "nodemon --exec babel-node src/ -e js,graphql",
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js -e js,graphql",
"dev": "nodemon --exec babel-node src/ -e js,gql",
"dev:debug": "nodemon --exec babel-node --inspect=0.0.0.0:9229 src/index.js -e js,gql",
"lint": "eslint src --config .eslintrc.js",
"test": "nyc --reporter=text-lcov yarn run test:jest",
"test:cypress": "run-p --race test:before:*",
Expand Down Expand Up @@ -54,6 +54,7 @@
"jsonwebtoken": "~8.5.0",
"linkifyjs": "~2.1.8",
"lodash": "~4.17.11",
"merge-graphql-schemas": "^1.5.8",
"ms": "~2.1.1",
"neo4j-driver": "~1.7.3",
"neo4j-graphql-js": "~2.4.2",
Expand Down
7 changes: 2 additions & 5 deletions src/graphql-schema.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import fs from 'fs'
import path from 'path'
import userManagement from './resolvers/user_management.js'
import statistics from './resolvers/statistics.js'
import reports from './resolvers/reports.js'
import posts from './resolvers/posts.js'
import moderation from './resolvers/moderation.js'
import types from './types'

export const typeDefs =
fs.readFileSync(process.env.GRAPHQL_SCHEMA || path.join(__dirname, 'schema.graphql'))
.toString('utf-8')
export const typeDefs = types

export const resolvers = {
Query: {
Expand Down
4 changes: 4 additions & 0 deletions src/schema.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
type Mutation {
disable(resource: Resource!): Boolean!
enable(resource: Resource!): Boolean!
}
289 changes: 0 additions & 289 deletions src/schema.graphql

This file was deleted.

23 changes: 23 additions & 0 deletions src/types/badge.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
enum BadgeTypeEnum {
role
crowdfunding
}
enum BadgeStatusEnum {
permanent
temporary
}

type Badge {
id: ID!
key: String!
type: BadgeTypeEnum!
status: BadgeStatusEnum!
icon: String!

rewarded: [User]! @relation(name: "REWARDED", direction: "OUT")
}

type User {
badges: [Badge]! @relation(name: "REWARDED", direction: "IN")
badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)")
}
3 changes: 3 additions & 0 deletions src/types/blacklist.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type User {
blacklisted: [User]! @relation(name: "BLACKLISTED", direction: "OUT")
}
20 changes: 20 additions & 0 deletions src/types/category.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type Category {
id: ID!
name: String!
slug: String
icon: String!
posts: [Post]! @relation(name: "CATEGORIZED", direction: "IN")
postCount: Int! @cypher(statement: "MATCH (this)<-[:CATEGORIZED]-(r:Post) RETURN COUNT(r)")
}

type Post {
categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
}

type Organization {
categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
}

type User {
categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
}
Loading