Skip to content

Commit

Permalink
Server implementation (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenwf committed Nov 2, 2018
1 parent 466aef2 commit d68cccc
Show file tree
Hide file tree
Showing 20 changed files with 1,600 additions and 207 deletions.
1 change: 1 addition & 0 deletions packages/iiif-graphql/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/dist
/node_modules
npm-debug.log*
/build
3 changes: 3 additions & 0 deletions packages/iiif-graphql/nwb.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
type: 'react-app',
babel: {
plugins: ['graphql-tag', require.resolve('babel-plugin-import-graphql')],
},
};
8 changes: 7 additions & 1 deletion packages/iiif-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@
"build": "nwb build-react-app",
"clean": "nwb clean-app",
"start": "nwb serve-react-app",
"server:dev": "graphpack",
"server:build": "graphpack build",
"test": "echo \"No tests yet\""
},
"dependencies": {
"iiif-redux": "1.0.0",
"apollo-cache-inmemory": "^1.3.5",
"apollo-client": "^2.4.2",
"apollo-link": "^1.2.3",
"apollo-link-schema": "^1.1.1",
"apollo-link-set-context": "^0.5.4",
"dataloader": "^1.4.0",
"graphql": "^14.0.2",
"graphql-tag": "^2.10.0",
"graphql-tools": "^4.0.1",
"iiif-redux": "1.0.0",
"react": "^16.5.2",
"react-apollo": "^2.2.4",
"react-dom": "^16.5.2"
},
"devDependencies": {
"babel-plugin-graphql-tag": "^1.6.0",
"babel-plugin-import-graphql": "^2.6.2",
"graphpack": "^1.0.0-alpha.3",
"nwb": "0.19.x"
},
"author": "",
Expand Down
48 changes: 0 additions & 48 deletions packages/iiif-graphql/src/App.css

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import './App.css';

import React, { Component } from 'react';
import { ApolloProvider } from 'react-apollo';
import HelloWorld from './components/HelloWorld';
import HelloWorld from './HelloWorld';

import client from './graphql/client';
import client from '../graphql/client';

class App extends Component {
state = {
Expand Down
3 changes: 0 additions & 3 deletions packages/iiif-graphql/src/components/HelloWorld.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ const queryText = gql`
value
}
}
getTest {
label
}
}
`;

Expand Down
7 changes: 7 additions & 0 deletions packages/iiif-graphql/src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import schemaDirectives from './graphql/directives';

const config = {
schemaDirectives,
};

export default config;
12 changes: 12 additions & 0 deletions packages/iiif-graphql/src/context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createStore } from 'iiif-redux';

const store = createStore();

const context = req => ({
store,
query: selector => {
return selector(store.getState());
},
});

export default context;
3 changes: 3 additions & 0 deletions packages/iiif-graphql/src/dataloaders/collections.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import DataLoader from 'dataloader';

const collectionLoader = new DataLoader({});
10 changes: 9 additions & 1 deletion packages/iiif-graphql/src/graphql/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ const store = createStore();
// ]);

const client = new ApolloClient({
link: new SchemaLink({ schema, context: { store } }),
link: new SchemaLink({
schema,
context: {
store,
query: selector => {
return selector(store.getState());
},
},
}),
cache: new InMemoryCache(),
});

Expand Down
57 changes: 0 additions & 57 deletions packages/iiif-graphql/src/graphql/resolvers.js

This file was deleted.

4 changes: 2 additions & 2 deletions packages/iiif-graphql/src/graphql/schema.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { makeExecutableSchema } from 'graphql-tools';

import typeDefs from './typeDefs';
import resolvers from './resolvers';
import typeDefs from '../schema.graphql';
import resolvers from '../resolvers';
import schemaDirectives from './directives';

const schema = makeExecutableSchema({
Expand Down
47 changes: 0 additions & 47 deletions packages/iiif-graphql/src/graphql/typeDefs.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/iiif-graphql/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import './index.css';
import React from 'react';
import { render } from 'react-dom';

import App from './App';
import App from './components/App';

render(<App />, document.querySelector('#app'));
Loading

0 comments on commit d68cccc

Please sign in to comment.