This repository has been archived by the owner on May 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Fi1osof
committed
Oct 27, 2018
1 parent
a972599
commit 189f96b
Showing
26 changed files
with
517 additions
and
124 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,48 @@ | ||
|
||
## Upload server for [@prisma-cms](https://github.com/prisma-cms) | ||
## Module boilerplate server for [@prisma-cms](https://github.com/prisma-cms) | ||
|
||
### Usage | ||
|
||
#### Standalone | ||
|
||
Download module | ||
|
||
``` | ||
git clone https://github.com/prisma-cms/upload-module | ||
cd upload-module | ||
yarn | ||
endpoint={NEW_PRISMA_ENDPOINT} yarn deploy | ||
endpoint={CREATED_PRISMA_ENDPOINT} yarn start | ||
git clone https://github.com/prisma-cms/module-boilerplate | ||
cd module-boilerplate | ||
``` | ||
Open in brouser http://localhost:4000 | ||
Install dependencies | ||
|
||
List of uploaded files: | ||
`yarn install` | ||
|
||
Update module schema | ||
|
||
`./module-boilerplate/src/modules/schema/` (see [instruction](https://github.com/prisma-cms/boilerplate#readme)) | ||
|
||
Deploy schema to prisma-server | ||
|
||
`endpoint={NEW_PRISMA_ENDPOINT} yarn deploy` | ||
|
||
Start server | ||
|
||
`endpoint={CREATED_PRISMA_ENDPOINT} yarn start` | ||
|
||
Open in brouser http://localhost:4000 | ||
|
||
``` | ||
query filesConnection{ | ||
filesConnection( | ||
first: 5 | ||
){ | ||
aggregate{ | ||
count | ||
} | ||
edges{ | ||
node{ | ||
id | ||
path | ||
filename | ||
mimetype | ||
encoding | ||
hash | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### Use as module for [@prisma-cms/boilerplate](https://github.com/prisma-cms/boilerplate) | ||
|
||
Just add as module in mergeModules here: https://github.com/prisma-cms/boilerplate/blob/master/src/server/modules/index.mjs | ||
|
||
#### Use [uploader](https://github.com/prisma-cms/uploader) component | ||
|
||
### [Component-boilerplate](https://github.com/prisma-cms/component-boilerplate) usage as front-end for module. | ||
|
||
``` | ||
git clone https://github.com/prisma-cms/uploader | ||
cd uploader | ||
git clone https://github.com/prisma-cms/component-boilerplate | ||
cd component-boilerplate | ||
yarn | ||
yarn start | ||
``` | ||
Open in brouser http://localhost:3000 | ||
|
||
Note that upload-module should work on port 4000 or configure [proxySetup](https://github.com/prisma-cms/uploader/blob/master/src/setupProxy.js). | ||
Note that *module-boilerplate* should work on port 4000 or configure [proxySetup](https://github.com/prisma-cms/component-boilerplate/blob/master/src/setupProxy.js). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
1.1.0 | ||
=============================== | ||
- Upgrade modules | ||
|
||
1.0.0 | ||
=============================== | ||
- First release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ignore": [ | ||
"*/generated/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
|
||
import chalk from "chalk"; | ||
|
||
import CmsModule from "../../../"; | ||
|
||
import InnerModule from "./innerModule"; | ||
|
||
|
||
import path from 'path'; | ||
import MergeSchema from 'merge-graphql-schemas'; | ||
|
||
const { fileLoader, mergeTypes } = MergeSchema | ||
const moduleURL = new URL(import.meta.url); | ||
const __dirname = path.dirname(moduleURL.pathname); | ||
|
||
|
||
class TestModule extends CmsModule { | ||
|
||
|
||
constructor(options = {}) { | ||
|
||
super(options); | ||
|
||
this.mergeModules([ | ||
// RouterModuleExtended, | ||
InnerModule, | ||
]); | ||
|
||
} | ||
|
||
|
||
getSchema(types = []) { | ||
|
||
let schema = fileLoader(__dirname + '/schema/database/', { | ||
recursive: true, | ||
}); | ||
|
||
|
||
if (schema) { | ||
types = types.concat(schema); | ||
} | ||
|
||
|
||
let typesArray = super.getSchema(types); | ||
|
||
return typesArray; | ||
|
||
} | ||
|
||
|
||
getApiSchema(types = []) { | ||
|
||
/** | ||
* Hack for imitate = "src/schema/generated/prisma.graphql"; | ||
*/ | ||
let baseSchema = this.getSchema(); | ||
|
||
// console.log("baseSchema", baseSchema); | ||
|
||
let apiSchema = super.getApiSchema(types.concat([baseSchema]), []); | ||
|
||
// console.log(chalk.green("TestModule apiSchema"), apiSchema); | ||
|
||
|
||
let schema = fileLoader(__dirname + '/schema/api/', { | ||
recursive: true, | ||
}); | ||
|
||
// apiSchema = mergeTypes([apiSchema.concat(schema).concat(baseSchema)], { all: true }); | ||
apiSchema = mergeTypes([apiSchema.concat(schema)], { all: true }); | ||
|
||
return apiSchema; | ||
|
||
} | ||
|
||
|
||
getExcludableApiTypes() { | ||
|
||
return super.getExcludableApiTypes([ | ||
// "UserCreateInput", | ||
// "User", | ||
// "EnumFields", | ||
]); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
export { | ||
CmsModule as PrismaModule, | ||
} | ||
|
||
export default TestModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
|
||
|
||
import chalk from "chalk"; | ||
|
||
import {PrismaModule} from "../"; | ||
|
||
import path from 'path'; | ||
import MergeSchema from 'merge-graphql-schemas'; | ||
const { fileLoader, mergeTypes } = MergeSchema | ||
const moduleURL = new URL(import.meta.url); | ||
const __dirname = path.dirname(moduleURL.pathname); | ||
|
||
|
||
|
||
class InnerModule extends PrismaModule { | ||
|
||
|
||
getSchema(types = []) { | ||
|
||
|
||
let schema = fileLoader(__dirname + '/schema/database/', { | ||
recursive: true, | ||
}); | ||
|
||
|
||
console.log(chalk.green("schema"), schema); | ||
|
||
|
||
if(schema){ | ||
types = types.concat(schema); | ||
} | ||
|
||
|
||
let typesArray = super.getSchema(types); | ||
|
||
return typesArray; | ||
|
||
} | ||
|
||
|
||
// getApiSchema(types = []) { | ||
|
||
// let schema = fileLoader(__dirname + '/schema/api/', { | ||
// recursive: true, | ||
// }); | ||
|
||
// // apiSchema = mergeTypes([apiSchema.concat(schema)], { all: true }); | ||
|
||
|
||
// return schema; | ||
|
||
// } | ||
|
||
|
||
|
||
|
||
getExcludableApiTypes() { | ||
|
||
return super.getExcludableApiTypes([ | ||
// "UserCreateInput", | ||
// "User", | ||
// "EnumFields", | ||
]); | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
export default InnerModule; | ||
|
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
enum TestEnumFields{ | ||
TestField | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
type TestUser { | ||
prismaTestUsername: String | ||
} | ||
|
||
input TestUserCreateInput { | ||
testUsername: String | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
type Query { | ||
testUsers: [TestUser!] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
type TestUser { | ||
testUsername: String | ||
prismaTestUsername: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
import expect from "expect"; | ||
|
||
import module from "./module"; | ||
|
||
const resolvers = module.getResolvers(); | ||
|
||
describe("Default module resolvers tests", () => { | ||
|
||
it("resolvers", () => { | ||
|
||
expect(typeof resolvers === "object").toBe(true); | ||
|
||
}); | ||
|
||
}); | ||
|
Oops, something went wrong.