Skip to content

Commit

Permalink
feat(viewer): add viewer field to RootQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
tothandras committed Oct 13, 2015
1 parent 63e7d99 commit f25c304
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"scripts": {
"start": "node --harmony src/index.js",
"test": "NODE_ENV=test mocha --harmony --compilers js:babel/register --require co-mocha $(find src -name \"*.spec.js\") && npm run eslint",
"test": "NODE_ENV=test mocha --compilers js:babel/register --require co-mocha 'src/**/*.spec.js'",
"eslint": "eslint src",
"prepublish": "npm test && npm run build",
"build": "rm -rf lib/* && babel src --ignore *.spec.js --out-dir lib"
Expand Down Expand Up @@ -45,7 +45,8 @@
"mongoose": "^4.1.8",
"pre-commit": "^1.1.1",
"sinon": "^1.15.4",
"sinon-chai": "^2.8.0"
"sinon-chai": "^2.8.0",
"graphql": "^0.4.4"
},
"pre-commit": [
"test"
Expand Down
10 changes: 9 additions & 1 deletion src/field/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,15 @@ function getFields(graffitiModels) {

const RootQuery = new GraphQLObjectType({
name: 'RootQuery',
fields: queries
fields: {
viewer: {
type: new GraphQLObjectType({
name: 'Viewer',
fields: queries
})
},
...queries
}
});

const RootMutation = new GraphQLObjectType({
Expand Down
10 changes: 10 additions & 0 deletions src/field/field.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ describe('field', () => {
fields: {
qux: {},
quxs: {},
viewer: {
type: {
_typeConfig: {
fields: {
qux: {},
quxs: {}
}
}
}
},
node: {
name: 'node',
args: {
Expand Down

0 comments on commit f25c304

Please sign in to comment.