-
Notifications
You must be signed in to change notification settings - Fork 25
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 #76 from cult-of-coders/feature/extend-arguments-m…
…orpher [R] Added access to all arguments from GraphQL resolvers
- Loading branch information
Showing
7 changed files
with
222 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { expose, db } from "meteor/cultofcoders:apollo"; | ||
import { Mongo } from "meteor/mongo"; | ||
|
||
export const TestCollection = new Mongo.Collection("tests"); | ||
|
||
expose({ | ||
users: { | ||
type: "User", | ||
collection: () => db.users, | ||
update: () => true, | ||
insert: () => true, | ||
remove: () => true, | ||
find: () => true | ||
} | ||
}); |
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,12 +1,84 @@ | ||
import { expose, db } from 'meteor/cultofcoders:apollo'; | ||
|
||
expose({ | ||
users: { | ||
type: 'User', | ||
collection: () => db.users, | ||
update: () => true, | ||
insert: () => true, | ||
remove: () => true, | ||
find: () => true, | ||
}, | ||
import "./bootstrap"; | ||
import { db } from "meteor/cultofcoders:apollo"; | ||
import setupMutations from "../../server/morpher/setupMutations"; | ||
import setupDataFetching from "../../server/morpher/setupDataFetching"; | ||
import { assert } from "chai"; | ||
|
||
describe("Unit tests", () => { | ||
it("Should send all the right args to the config functions", () => { | ||
const testRest = [ | ||
{}, | ||
{ | ||
payload: JSON.stringify({ | ||
document: { a: 1 }, | ||
selector: {}, | ||
modifier: {} | ||
}) | ||
}, | ||
{}, | ||
{} | ||
]; | ||
|
||
const checkArray = rest => { | ||
assert.equal(4, rest.length); | ||
|
||
for (let i = 0; i < testRest.length; i++) { | ||
if (i === 1) { | ||
continue; | ||
} | ||
assert.strictEqual(testRest[i], rest[i]); | ||
} | ||
|
||
// assert.equal(rest[1], {}); | ||
}; | ||
|
||
let count = 0; | ||
|
||
const { Mutation } = setupMutations( | ||
{ | ||
insert(ctx, special, ...rest) { | ||
checkArray(rest); | ||
count++; | ||
}, | ||
update(ctx, special, ...rest) { | ||
checkArray(rest); | ||
count++; | ||
}, | ||
remove(ctx, special, ...rest) { | ||
checkArray(rest); | ||
count++; | ||
} | ||
}, | ||
"test", | ||
"TestEntity", | ||
() => db.tests | ||
); | ||
|
||
const { Query } = setupDataFetching( | ||
{ | ||
find(ctx, special, ...rest) { | ||
count++; | ||
checkArray(rest); | ||
} | ||
}, | ||
"test", | ||
"TestEntity", | ||
() => db.tests | ||
); | ||
|
||
const safeRun = fn => { | ||
try { | ||
fn(); | ||
} catch (e) {} | ||
}; | ||
safeRun(() => Mutation.testInsert(...testRest)); | ||
safeRun(() => Mutation.testUpdate(...testRest)); | ||
safeRun(() => Mutation.testRemove(...testRest)); | ||
|
||
safeRun(() => Query.test(...testRest)); | ||
safeRun(() => Query.testSingle(...testRest)); | ||
safeRun(() => Query.testCount(...testRest)); | ||
|
||
assert.equal(count, 6); | ||
}); | ||
}); |
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,49 +1,49 @@ | ||
Package.describe({ | ||
name: 'cultofcoders:apollo', | ||
version: '0.9.3', | ||
name: "cultofcoders:apollo", | ||
version: "0.9.3", | ||
// Brief, one-line summary of the package. | ||
summary: 'Meteor & Apollo integration', | ||
summary: "Meteor & Apollo integration", | ||
// URL to the Git repository containing the source code for this package. | ||
git: 'https://github.com/cult-of-coders/apollo.git', | ||
git: "https://github.com/cult-of-coders/apollo.git", | ||
// By default, Meteor will default to using README.md for documentation. | ||
// To avoid submitting documentation, set this field to null. | ||
documentation: 'README.md', | ||
documentation: "README.md" | ||
}); | ||
|
||
Package.onUse(function(api) { | ||
api.versionsFrom('1.3'); | ||
api.use('ecmascript'); | ||
api.use('check'); | ||
api.use('ejson'); | ||
api.use('mongo'); | ||
|
||
api.use('tmeasday:check-npm-versions@0.3.2'); | ||
api.use('cultofcoders:grapher@1.3.13'); | ||
api.use('cultofcoders:grapher-schema-directives@0.1.8'); | ||
api.use('accounts-base', { weak: true }); | ||
|
||
api.mainModule('client/index.js', 'client'); | ||
api.mainModule('server/index.js', 'server'); | ||
api.versionsFrom("1.3"); | ||
api.use("ecmascript"); | ||
api.use("check"); | ||
api.use("ejson"); | ||
api.use("mongo"); | ||
|
||
api.use("tmeasday:check-npm-versions@0.3.2"); | ||
api.use("cultofcoders:grapher@1.3.13"); | ||
api.use("cultofcoders:grapher-schema-directives@0.1.8"); | ||
api.use("accounts-base", { weak: true }); | ||
|
||
api.mainModule("client/index.js", "client"); | ||
api.mainModule("server/index.js", "server"); | ||
}); | ||
|
||
Npm.depends({ | ||
cookie: '0.4.0', | ||
cookie: "0.4.0" | ||
}); | ||
|
||
Package.onTest(function(api) { | ||
api.use('cultofcoders:apollo'); | ||
api.use("cultofcoders:apollo"); | ||
|
||
var packages = [ | ||
'ecmascript', | ||
'accounts-password', | ||
'cultofcoders:apollo-accounts@3.4.0', | ||
'mongo', | ||
"ecmascript", | ||
"accounts-password", | ||
"cultofcoders:apollo-accounts@3.4.0", | ||
"mongo" | ||
]; | ||
|
||
api.use(['meteortesting:mocha']); | ||
api.use(["meteortesting:mocha"]); | ||
|
||
api.use(packages); | ||
|
||
api.mainModule('__tests__/server.js', 'server'); | ||
api.mainModule('__tests__/client.js', 'client'); | ||
api.mainModule("__tests__/server.js", "server"); | ||
api.mainModule("__tests__/client.js", "client"); | ||
}); |
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
Oops, something went wrong.