Skip to content

Commit 643ec87

Browse files
committed
Initial commit
0 parents  commit 643ec87

File tree

10 files changed

+185
-0
lines changed

10 files changed

+185
-0
lines changed

.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": ["react"],
3+
"plugins": ["dev-expression", "transform-runtime"],
4+
5+
"env": {
6+
"cjs": {
7+
"presets": ["es2015-loose", "stage-0"],
8+
"plugins": ["add-module-exports"]
9+
},
10+
"es": {
11+
"presets": ["es2015-loose-native-modules", "stage-0"]
12+
}
13+
}
14+
}

.eslintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "airbnb",
3+
"parser": "babel-eslint",
4+
"rules": {
5+
"no-underscore-dangle": 0
6+
}
7+
}

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
15+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
16+
.grunt
17+
18+
# node-waf configuration
19+
.lock-wscript
20+
21+
# Compiled binary addons (http://nodejs.org/api/addons.html)
22+
build/Release
23+
24+
# IntelliJ Files
25+
*.iml
26+
*.ipr
27+
*.iws
28+
/out/
29+
.idea/
30+
.idea_modules/
31+
32+
# Dependency directory
33+
node_modules
34+
35+
# Optional npm cache directory
36+
.npm
37+
38+
# Optional REPL history
39+
.node_repl_history
40+
41+
# Transpiled code
42+
/es
43+
/lib

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
*.log
3+
src

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Pavel Chertorogov <pavel.chertorogov@gmail.com>

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## master
2+
3+
## 0.0.1 (July 04, 2016)
4+
* Initial commit

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016-present Pavel Chertorogov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
graphql-compose-relay
2+
======================
3+
This is a plugin for `graphql-compose`, which wraps graphql types and resolvers with Relay specific things, like `Node` type and interface, `globalId`, `clientMutationId`.
4+
5+
To-Do
6+
=====
7+
- [ ] realize `clientMutationId` for resolvers with `kind = 'mutation'`
8+
- [ ] realize `globalId` wrapper for Id fields
9+
- [ ] create `Node` type, interface and type resolver
10+
11+
12+
[CHANGELOG](https://github.com/nodkz/graphql-compose-relay/blob/master/CHANGELOG.md)
13+
14+
License
15+
=======
16+
[MIT](https://github.com/nodkz/graphql-compose-relay/blob/master/LICENSE.md)

package.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "graphql-compose-relay",
3+
"version": "0.0.1",
4+
"description": "Plugin for `graphql-mongoose` which wraps graphql types with Relay specific logic.",
5+
"files": [
6+
"es",
7+
"lib"
8+
],
9+
"main": "lib/index.js",
10+
"jsnext:main": "es/index.js",
11+
"scripts": {
12+
"build": "npm run build-cjs && npm run build-es",
13+
"build-cjs": "rimraf lib && BABEL_ENV=cjs babel src -d lib",
14+
"build-es": "rimraf es && BABEL_ENV=es babel src -d es",
15+
"lint": "eslint src test *.js",
16+
"prepublish": "npm run build",
17+
"test": "npm run lint"
18+
},
19+
"repository": {
20+
"type": "git",
21+
"url": "git+https://github.com/nodkz/graphql-compose-relay.git"
22+
},
23+
"keywords": [
24+
"graphql",
25+
"compose"
26+
],
27+
"license": "MIT",
28+
"bugs": {
29+
"url": "https://github.com/nodkz/graphql-compose-relay/issues"
30+
},
31+
"homepage": "https://github.com/nodkz/graphql-compose-relay",
32+
"dependencies": {
33+
"babel-runtime": "^6.6.1",
34+
"graphql": "^0.5.0"
35+
},
36+
"devDependencies": {
37+
"babel-cli": "^6.7.7",
38+
"babel-core": "^6.7.7",
39+
"babel-eslint": "^6.0.3",
40+
"babel-loader": "^6.2.4",
41+
"babel-plugin-add-module-exports": "^0.1.2",
42+
"babel-plugin-dev-expression": "^0.2.1",
43+
"babel-plugin-transform-runtime": "^6.7.5",
44+
"babel-polyfill": "^6.7.4",
45+
"babel-preset-es2015": "^6.6.0",
46+
"babel-preset-es2015-loose": "^7.0.0",
47+
"babel-preset-es2015-loose-native-modules": "^1.0.0",
48+
"babel-preset-stage-0": "^6.5.0",
49+
"babel-register": "^6.7.2",
50+
"babel-relay-plugin": "^0.8.0",
51+
"eslint": "^2.8.0",
52+
"eslint-config-airbnb": "^7.0.0",
53+
"eslint-plugin-jsx-a11y": "^0.6.2",
54+
"eslint-plugin-react": "^4.3.0",
55+
"rimraf": "^2.5.2"
56+
}
57+
}

src/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { GraphQLSchema } from 'graphql';
2+
import compose from './compose';
3+
4+
function initGraphqlTypes() {
5+
// populate root types in Storage.Types
6+
getViewerType();
7+
getRootQueryType();
8+
getRootMutationType();
9+
10+
// now all types declared, we are ready to extend types
11+
resolveUnresolvedRefs();
12+
addAdditionalFields();
13+
}
14+
15+
function getSchema() {
16+
initGraphqlTypes();
17+
18+
const schemaConfig = { query: getRootQueryType() };
19+
20+
if (Storage.AdditionalFields.has('RootMutation')) {
21+
schemaConfig.mutation = getRootMutationType();
22+
}
23+
24+
return new GraphQLSchema(schemaConfig);
25+
}
26+
27+
28+
export {
29+
getSchema,
30+
};
31+

0 commit comments

Comments
 (0)