-
Notifications
You must be signed in to change notification settings - Fork 26
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
Showing
7 changed files
with
132 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { GraphQLObjectType, GraphQLString, GraphQLList } from 'graphql'; | ||
|
||
import YdocVersion from './YdocVersion'; | ||
|
||
const Ydoc = new GraphQLObjectType({ | ||
name: 'Ydoc', | ||
fields: () => ({ | ||
data: { | ||
type: GraphQLString, | ||
// https://www.elastic.co/guide/en/elasticsearch/reference/current/binary.html | ||
description: 'Binary that stores as base64 encoded string', | ||
}, | ||
versions: { | ||
type: new GraphQLList(YdocVersion), | ||
}, | ||
}), | ||
}); | ||
|
||
export default Ydoc; |
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,13 @@ | ||
import { GraphQLObjectType, GraphQLString } from 'graphql'; | ||
|
||
export default new GraphQLObjectType({ | ||
name: 'YdocVersion', | ||
fields: () => ({ | ||
createdAt: { type: GraphQLString }, | ||
snapshot: { | ||
type: GraphQLString, | ||
// https://www.elastic.co/guide/en/elasticsearch/reference/current/binary.html | ||
description: 'Binary that stores as base64 encoded string', | ||
}, | ||
}), | ||
}); |
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 { GraphQLString } from 'graphql'; | ||
|
||
import Ydoc from 'graphql/models/Ydoc'; | ||
|
||
export default { | ||
type: Ydoc, | ||
args: { | ||
id: { type: GraphQLString }, | ||
}, | ||
resolve: async (rootValue, { id }, { loaders }) => | ||
loaders.docLoader.load({ index: 'ydocs', id }), | ||
}; |
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 @@ | ||
export default { | ||
'/ydocs/doc/foo': { | ||
data: '', | ||
versions: [ | ||
{ | ||
createdAt: '2020-02-09T15:11:04.472Z', | ||
snapshot: '', | ||
}, | ||
{ | ||
createdAt: '2020-02-09T15:11:04.472Z', | ||
snapshot: '', | ||
}, | ||
{ | ||
createdAt: '2020-02-09T15:11:04.472Z', | ||
snapshot: '', | ||
}, | ||
{ | ||
createdAt: '2020-02-09T15:11:04.472Z', | ||
snapshot: '', | ||
}, | ||
], | ||
}, | ||
'/articles/doc/foo2': { | ||
data: '', | ||
versions: [], | ||
}, | ||
'/articles/doc/foo3': { | ||
data: '', | ||
versions: [], | ||
}, | ||
}; |
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 @@ | ||
import gql from 'util/GraphQL'; | ||
import { loadFixtures, unloadFixtures } from 'util/fixtures'; | ||
import fixtures from '../__fixtures__/GetYdoc'; | ||
|
||
describe('GetReplyAndGetArticle', () => { | ||
beforeAll(() => loadFixtures(fixtures)); | ||
|
||
describe('GetYdoc', () => { | ||
it('should get the specified article & associated replies from ID', async () => { | ||
expect( | ||
await gql` | ||
{ | ||
GetYdoc(id: "foo") { | ||
data | ||
versions { | ||
createdAt | ||
snapshot | ||
} | ||
} | ||
} | ||
`({}, { user: { id: 'fakeUser', appId: 'LINE' } }) | ||
).toMatchSnapshot(); | ||
}); | ||
}); | ||
afterAll(() => unloadFixtures(fixtures)); | ||
}); |
29 changes: 29 additions & 0 deletions
29
src/graphql/queries/__tests__/__snapshots__/GetYdoc.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,29 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`GetReplyAndGetArticle GetYdoc should get the specified article & associated replies from ID 1`] = ` | ||
Object { | ||
"data": Object { | ||
"GetYdoc": Object { | ||
"data": "", | ||
"versions": Array [ | ||
Object { | ||
"createdAt": "2020-02-09T15:11:04.472Z", | ||
"snapshot": "", | ||
}, | ||
Object { | ||
"createdAt": "2020-02-09T15:11:04.472Z", | ||
"snapshot": "", | ||
}, | ||
Object { | ||
"createdAt": "2020-02-09T15:11:04.472Z", | ||
"snapshot": "", | ||
}, | ||
Object { | ||
"createdAt": "2020-02-09T15:11:04.472Z", | ||
"snapshot": "", | ||
}, | ||
], | ||
}, | ||
}, | ||
} | ||
`; |
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