-
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.
- Loading branch information
1 parent
584eb04
commit 7a7b1f2
Showing
31 changed files
with
778 additions
and
229 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import './morpher/morpher.test'; |
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,4 @@ | ||
import { load } from 'meteor/cultofcoders:apollo'; | ||
import { typeDefs } from './module'; | ||
|
||
load({ typeDefs }); |
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,26 @@ | ||
const typeDefs = ` | ||
type User @mongo(name:"users") { | ||
_id: ID! | ||
firstName: String | ||
lastName: String | ||
posts: [Post] @link(to: "author") | ||
comments: [Comment] @link(to: "user") | ||
} | ||
type Post @mongo(name:"posts") { | ||
_id: ID! | ||
name: String | ||
author: User @link(field: "authorId") | ||
authorId: String | ||
comments: [Comment] @link(to: "post") | ||
} | ||
type Comment @mongo(name:"comments") { | ||
_id: ID! | ||
text: String | ||
user: User @link(field: "userId") | ||
post: Post @link(field: "postId") | ||
} | ||
`; | ||
|
||
export { typeDefs }; |
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,8 @@ | ||
import { initialize } from 'meteor/cultofcoders:apollo'; | ||
import { setClient } from 'apollo-morpher'; | ||
|
||
const { client } = initialize(); | ||
|
||
setClient(client); | ||
|
||
export default 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { expose, db } from 'meteor/cultofcoders:apollo'; | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import db from 'apollo-morpher'; | ||
import client from './client'; | ||
|
||
describe('Morpher', () => { | ||
it('Should work with insert()', done => { | ||
db.users | ||
.insert({ | ||
firstName: 'John', | ||
lastName: 'Smith', | ||
}) | ||
.then(result => { | ||
assert.isString(result._id); | ||
done(); | ||
}); | ||
}); | ||
it('Should work with update()', async () => { | ||
const { _id } = await db.users.insert({ | ||
firstName: 'John', | ||
lastName: 'Smith', | ||
}); | ||
|
||
const response = await db.users.update( | ||
{ _id }, | ||
{ | ||
$set: { lastName: 'Brown' }, | ||
} | ||
); | ||
|
||
assert.equal('ok', response); | ||
}); | ||
|
||
it('Should work with remove()', async () => { | ||
const { _id } = await db.users.insert({ | ||
firstName: 'John', | ||
lastName: 'Smith', | ||
}); | ||
|
||
const response = await db.users.remove({ _id }); | ||
|
||
assert.equal('ok', response); | ||
}); | ||
|
||
it('Should work with find()', async () => { | ||
const { _id } = await db.users.insert({ | ||
firstName: 'John', | ||
lastName: 'Smith', | ||
}); | ||
|
||
const users = await db.users.find( | ||
{ | ||
_id: 1, | ||
firstName: 1, | ||
lastName: 1, | ||
}, | ||
{ | ||
filters: { _id }, | ||
} | ||
); | ||
|
||
assert.lengthOf(users, 1); | ||
assert.isObject(users[0]); | ||
assert.equal(_id, users[0]._id); | ||
assert.equal('John', users[0].firstName); | ||
assert.equal('Smith', users[0].lastName); | ||
}); | ||
|
||
it('Should work with findOne()', async () => { | ||
const { _id } = await db.users.insert({ | ||
firstName: 'John', | ||
lastName: 'Smith', | ||
}); | ||
|
||
const user = await db.users.findOne( | ||
{ | ||
_id: 1, | ||
firstName: 1, | ||
lastName: 1, | ||
}, | ||
{ | ||
filters: { _id }, | ||
} | ||
); | ||
|
||
assert.isObject(user); | ||
assert.equal(_id, user._id); | ||
assert.equal('John', user.firstName); | ||
assert.equal('Smith', user.lastName); | ||
}); | ||
}); |
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 @@ | ||
import { initialize } from 'meteor/cultofcoders:apollo'; | ||
import './graphql/init'; | ||
import './morpher/init.server'; | ||
|
||
initialize(); |
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 |
---|---|---|
|
@@ -149,4 +149,4 @@ load({ | |
|
||
--- | ||
|
||
### [Table of Contents](table-of-contents.md) | ||
### [Table of Contents](index.md) |
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
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,17 @@ | ||
# Table of Contents | ||
|
||
Hi there, if anythings are unclear, please help us improve this documentation by asking questions as issues, | ||
and doing a PR to fix it. Thank you! | ||
|
||
- [Simple Usage](sample.md) | ||
- [Work with Database](db.md) | ||
- [Morph your database](morpher.md) | ||
- [Accounts](accounts.md) | ||
- [Scalars](scalars.md) | ||
- [Live Queries](live_queries.md) | ||
- [Client](client.md) | ||
- [DDP](ddp.md) | ||
- [Visualising](visualising.md) | ||
- [Settings](settings.md) | ||
- [React-Native Client Considerations](react-native-client.md) | ||
- [Meteor Connectivty Simulation](meteor-connectivity.md) |
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.