-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from lucasbento/plugins
Add very early initial draft of plugins
- Loading branch information
Showing
37 changed files
with
5,170 additions
and
17 deletions.
There are no files selected for viewing
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
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,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-0"] | ||
} |
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,3 @@ | ||
src | ||
npm-debug.log | ||
coverage |
22 changes: 22 additions & 0 deletions
22
packages/create-graphql-core/fixtures/mongoose-type/.graphqlrc
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,22 @@ | ||
{ | ||
"plugins": [ | ||
"mongoose", | ||
"type" | ||
], | ||
"paths": { | ||
"directories": { | ||
"source": "src", | ||
"connection": "connection", | ||
"loader": "loader", | ||
"model": "model", | ||
"mutation": "mutation", | ||
"mutation_test": "mutation/__tests__", | ||
"type": "type", | ||
"type_test": "type/__tests__", | ||
"interface": "interface" | ||
}, | ||
"files": { | ||
"schema": "schema" | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
packages/create-graphql-core/fixtures/mongoose-type/src/model/Post.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import mongoose from 'mongoose'; | ||
|
||
import User from './User'; | ||
const { ObjectId } = mongoose.Schema.Types; | ||
|
||
const Schema = new mongoose.Schema({ | ||
title: { | ||
type: String, | ||
maxlength: 120, | ||
required: true, | ||
}, | ||
user: { | ||
type: ObjectId, | ||
ref: 'User', | ||
description: 'User that created this post', | ||
required: true, | ||
}, | ||
slug: { | ||
type: String, | ||
indexed: true, | ||
description: 'Used for SEO', | ||
}, | ||
}, { | ||
timestamps: { | ||
createdAt: 'createdAt', | ||
updatedAt: 'updatedAt', | ||
}, | ||
collection: 'post', | ||
}); | ||
|
||
export default mongoose.model('Post', Schema); |
29 changes: 29 additions & 0 deletions
29
packages/create-graphql-core/fixtures/mongoose-type/src/model/User.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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// @flow | ||
import mongoose from 'mongoose'; | ||
|
||
const Schema = new mongoose.Schema({ | ||
name: { | ||
type: String, | ||
description: 'user name', | ||
required: true, | ||
}, | ||
password: { | ||
type: String, | ||
description: 'hashed user password', | ||
hidden: true, | ||
}, | ||
email: { | ||
type: String, | ||
required: false, | ||
description: 'user email', | ||
index: true, | ||
}, | ||
active: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, { | ||
collection: 'user', | ||
}); | ||
|
||
export default mongoose.model('User', Schema); |
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,56 @@ | ||
{ | ||
"name": "create-graphql-core", | ||
"description": "Create GraphQL core", | ||
"version": "1.1.16", | ||
"author": { | ||
"name": "Lucas Bento", | ||
"email": "lucas.bsilva@outlook.com", | ||
"url": "https://github.com/lucasbento" | ||
}, | ||
"bugs": "https://github.com/lucasbento/create-graphql/issues", | ||
"dependencies": { | ||
"babel-generator": "^6.24.0", | ||
"babel-polyfill": "^6.20.0", | ||
"babel-template": "^6.23.0", | ||
"babel-types": "^6.23.0", | ||
"babylon": "^6.16.1", | ||
"chalk": "^1.1.3", | ||
"colors": "^1.1.2", | ||
"es-module-loader": "^2.1.4", | ||
"lodash.merge": "^4.6.0", | ||
"ora": "^0.4.0", | ||
"pkg-dir": "^1.0.0", | ||
"pluralize": "^3.1.0", | ||
"ramda": "^0.22.1", | ||
"recast": "^0.12.2", | ||
"semver": "^5.1.0", | ||
"shelljs": "^0.7.4", | ||
"yeoman-generator": "^1.0.1" | ||
}, | ||
"devDependencies": {}, | ||
"homepage": "https://github.com/lucasbento/create-graphql#readme", | ||
"keywords": [ | ||
"apollo", | ||
"create", | ||
"generator", | ||
"graphql", | ||
"koa", | ||
"relay", | ||
"server", | ||
"yeoman", | ||
"yo", | ||
"yeoman-generator" | ||
], | ||
"license": "MIT", | ||
"preferGlobal": true, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/lucasbento/create-graphql" | ||
}, | ||
"scripts": { | ||
"build": "npm run clear && babel src --ignore *.spec.js --out-dir dist", | ||
"clear": "rimraf ./dist", | ||
"test": "jest", | ||
"watch": "babel -w -d ./dist ./src --copy-files" | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
packages/create-graphql-core/src/__tests__/__snapshots__/core.spec.js.snap
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,19 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should call getFields of first plugin, and generateTemplate from the second one 1`] = ` | ||
Array [ | ||
"export default new GraphQLObjectType({ | ||
name: \\"User\\", | ||
description: 'Represents NAME', | ||
fields: () => ({ | ||
id: globalIdField('NAME'), | ||
example: { | ||
type: GraphQLString, | ||
description: 'My example field', | ||
resolve: obj => obj.example | ||
} | ||
}), | ||
interfaces: () => [NodeInterface] | ||
});", | ||
] | ||
`; |
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,24 @@ | ||
import path from 'path'; | ||
import core from '../index'; | ||
|
||
/** | ||
* Get a fixture path | ||
* @param name {string} Name of the file of the fixture | ||
* @returns {string} The path of the fixture | ||
*/ | ||
const getFixturePath = name => path.join(__dirname, `../../fixtures/${name}`); | ||
|
||
it('should call getFields of first plugin, and generateTemplate from the second one', async () => { | ||
const testName = 'mongoose-type'; | ||
const testPath = getFixturePath(testName); | ||
|
||
const opts = { | ||
plugins: ['mongoose', 'type'], | ||
name: 'User', | ||
schema: 'User', | ||
}; | ||
|
||
const templates = await core(testPath, opts); | ||
|
||
expect(templates).toMatchSnapshot(); | ||
}); |
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,18 @@ | ||
{ | ||
"paths": { | ||
"directories": { | ||
"source": "src", | ||
"connection": "connection", | ||
"loader": "loader", | ||
"model": "model", | ||
"mutation": "mutation", | ||
"mutation_test": "mutation/__tests__", | ||
"type": "type", | ||
"type_test": "type/__tests__", | ||
"interface": "interface" | ||
}, | ||
"files": { | ||
"schema": "schema" | ||
} | ||
} | ||
} |
Oops, something went wrong.