Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions todo/data/fixture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export const fixture = {
"appQuery": {
"todos": {
"edges": [
{
"node": {
"id": "VG9kbzow",
"__typename": "Todo",
"text": "This's a fixture"
},
"cursor": "YXJyYXljb25uZWN0aW9uOjA="
},
{
"node": {
"id": "VG9kbzox",
"__typename": "Todo",
"text": "Created with easygraphql-tester"
},
"cursor": "YXJyYXljb25uZWN0aW9uOjE="
}
]
}
}
}
17 changes: 17 additions & 0 deletions todo/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,30 @@ import 'todomvc-common';

import React from 'react';
import ReactDOM from 'react-dom';
import EasyGraphQLTester from 'easygraphql-tester';
import { schema } from '../data/schema';
import { fixture } from '../data/fixture';

import {QueryRenderer, graphql} from 'react-relay';
import {Environment, Network, RecordSource, Store} from 'relay-runtime';

import TodoApp from './components/TodoApp';

const tester = new EasyGraphQLTester(schema);

function fetchQuery(operation, variables) {
if (process.env.NODE_ENV === 'none') {
const mockedQuery = tester.mock({
query: operation.text,
variables,
fixture: fixture[operation.name]
})
const response = {
"data": mockedQuery
}
return response
}

return fetch('/graphql', {
method: 'POST',
headers: {
Expand Down
Loading