Skip to content

Commit c24d73b

Browse files
committed
updated meteor-integration
1 parent 69cc2e7 commit c24d73b

File tree

8 files changed

+93
-88
lines changed

8 files changed

+93
-88
lines changed

app/.meteor/versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ aldeed:schema-deny@1.1.0
1010
aldeed:schema-index@1.1.0
1111
aldeed:simple-schema@1.5.3
1212
allow-deny@1.0.5
13-
apollo@0.2.1
13+
apollo@0.3.1
1414
autoupdate@1.3.12
1515
babel-compiler@6.13.0
1616
babel-runtime@1.0.1

app/package.json

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,29 @@
1313
"prestart": "npm run generate-graphql-documents; npm run generate-graphql-types"
1414
},
1515
"dependencies": {
16-
"apollo-client": "^0.5.0",
17-
"apollo-client-rxjs": "^0.2.4",
18-
"bcrypt": "^0.8.7",
16+
"apollo-client": "^0.8.4",
17+
"apollo-client-rxjs": "^0.5.1",
18+
"bcrypt": "^1.0.2",
1919
"bluebird": "^3.4.1",
2020
"body-parser": "^1.15.2",
2121
"bootstrap": "^3.3.7",
2222
"cdm-logger": "1.0.7",
23-
"cheerio": "^0.20.0",
23+
"cheerio": "^0.22.0",
2424
"cookie-monster": "^0.2.0",
2525
"cookie-parser": "^1.4.3",
2626
"dataloader": "^1.2.0",
27-
"deepmerge": "^0.2.10",
27+
"deepmerge": "^1.3.2",
2828
"diff-match-patch": "^1.0.0",
2929
"express": "^4.14.0",
3030
"formatjs": "^0.1.1",
31-
"graphql": "^0.8.2",
31+
"graphql": "^0.9.1",
32+
"graphql-anywhere": "^2.2.0",
3233
"graphql-custom-types": "^0.7.1",
3334
"graphql-schema-collector": "0.2.4",
34-
"graphql-server-express": "^0.4.3",
35-
"graphql-subscriptions": "^0.2.2",
36-
"graphql-tag": "1.2.1",
37-
"graphql-tools": "^0.8.4",
35+
"graphql-server-express": "^0.6.0",
36+
"graphql-subscriptions": "^0.3.0",
37+
"graphql-tag": "1.2.4",
38+
"graphql-tools": "^0.10.0",
3839
"graphql-typings": "0.0.1-beta-2",
3940
"immutable": "^3.8.1",
4041
"intl-locales-supported": "^1.0.0",
@@ -48,12 +49,13 @@
4849
"meteor-node-stubs": "^0.2.3",
4950
"mime": "^1.3.4",
5051
"nconf": "^0.8.4",
51-
"node-sass": "^3.8.0",
52-
"ramda": "^0.22.1",
52+
"node-sass": "^4.5.0",
53+
"persistgraphql": "^0.2.10",
54+
"ramda": "^0.23.0",
5355
"randomstring": "^1.1.5",
5456
"raven-js": "^3.3.0",
5557
"react": "^15.4.0",
56-
"react-ace": "^3.6.1",
58+
"react-ace": "^4.1.4",
5759
"react-addons-create-fragment": "^15.3.0",
5860
"react-addons-css-transition-group": "^15.3.0",
5961
"react-addons-linked-state-mixin": "^15.3.0",
@@ -62,49 +64,48 @@
6264
"react-addons-test-utils": "^15.3.0",
6365
"react-addons-transition-group": "^15.3.0",
6466
"react-addons-update": "^15.3.0",
65-
"react-apollo": "^0.7.0",
67+
"react-apollo": "^0.10.0",
6668
"react-bootstrap": "^0.30.2",
67-
"react-codemirror": "^0.2.6",
69+
"react-codemirror": "^0.3.0",
6870
"react-cookie": "^1.0.4",
6971
"react-dom": "^15.2.0",
7072
"react-ga": "^2.1.2",
71-
"react-helmet": "^3.1.0",
73+
"react-helmet": "^4.0.0",
7274
"react-intl": "^2.1.3",
7375
"react-komposer": "^2.0.0",
7476
"react-loader": "^2.4.0",
7577
"react-mixin": "^3.0.5",
7678
"react-pure-render": "^1.0.2",
77-
"react-redux": "^4.4.5",
78-
"react-redux-transaction": "0.0.9",
79+
"react-redux": "^5.0.2",
7980
"react-router": "^3.0.0",
8081
"react-router-bootstrap": "^0.23.1",
8182
"react-router-redux": "^4.0.7",
8283
"rebass": "^0.3.3",
83-
"recompose": "^0.20.2",
84+
"recompose": "^0.22.0",
8485
"redux": "^3.5.2",
8586
"redux-devtools": "^3.3.1",
8687
"redux-devtools-dock-monitor": "^1.1.1",
8788
"redux-devtools-log-monitor": "^1.0.11",
8889
"redux-logger": "^2.6.1",
89-
"redux-observable": "^0.12.2",
90-
"redux-persist": "^3.5.0",
90+
"redux-observable": "^0.13.0",
91+
"redux-persist": "^4.3.0",
9192
"redux-storage": "^4.1.0",
9293
"redux-storage-decorator-debounce": "^1.0.1",
9394
"redux-storage-engine-localstorage": "^1.1.1",
9495
"redux-thunk": "^2.1.0",
9596
"redux-transaction": "0.0.5",
9697
"reflexbox": "^2.1.0",
9798
"rxjs": "^5.0.1",
98-
"sass-loader": "^4.0.0",
99+
"sass-loader": "^5.0.1",
99100
"shortid": "^2.2.6",
100-
"subscriptions-transport-ws": "^0.3.1",
101+
"subscriptions-transport-ws": "^0.5.1",
101102
"tracker-component": "^1.3.21",
102-
"transit-immutable-js": "^0.6.0",
103+
"transit-immutable-js": "^0.7.0",
103104
"transit-js": "^0.8.846",
104-
"validator": "^5.5.0"
105+
"validator": "^6.2.1"
105106
},
106107
"devDependencies": {
107-
"apollo-codegen": "^0.9.6",
108+
"apollo-codegen": "^0.10.6",
108109
"babel": "^6.3.26",
109110
"babel-core": "^6.6.0",
110111
"babel-eslint": "^7.1.1",
@@ -118,22 +119,22 @@
118119
"babel-preset-react": "^6.3.13",
119120
"babel-preset-stage-0": "^6.3.13",
120121
"babel-runtime": "^6.18.0",
121-
"css-loader": "^0.23.0",
122+
"css-loader": "^0.26.1",
122123
"enzyme": "^2.4.1",
123124
"eslint": "^3.12.2",
124-
"eslint-config-airbnb": "^13.0.0",
125+
"eslint-config-airbnb": "^14.1.0",
125126
"eslint-import-resolver-meteor": "^0.3.4",
126127
"eslint-plugin-flowtype": "^2.29.0",
127128
"eslint-plugin-fp": "^2.2.0",
128-
"eslint-plugin-graphql": "^0.4.3",
129+
"eslint-plugin-graphql": "^0.6.0",
129130
"eslint-plugin-import": "^2.2.0",
130-
"eslint-plugin-jsx-a11y": "^2.2.3",
131+
"eslint-plugin-jsx-a11y": "^4.0.0",
131132
"eslint-plugin-meteor": "^4.0.1",
132133
"eslint-plugin-react": "^6.8.0",
133134
"expose-loader": "^0.7.1",
134135
"extract-text-webpack-plugin": "^1.0.0",
135136
"file-loader": "^0.8.5",
136-
"flow-bin": "^0.32.0",
137+
"flow-bin": "^0.39.0",
137138
"graphql-document-collector": "^0.1.1",
138139
"html-loader": "^0.4.0",
139140
"json-loader": "^0.5.4",
@@ -143,12 +144,12 @@
143144
"react-transform-hmr": "^1.0.1",
144145
"redbox-react": "^1.2.0",
145146
"style-loader": "^0.13.0",
146-
"ts-loader": "^0.8.1",
147-
"typescript": "^1.8.7",
147+
"ts-loader": "^2.0.0",
148+
"typescript": "^2.1.6",
148149
"typings": "^2.0.0",
149150
"url-loader": "^0.5.7",
150151
"source-map-support": "^0.4.9",
151-
"webpack": "^1.13.0",
152+
"webpack": "^2.2.1",
152153
"webpack-hot-middleware": "^2.4.1"
153154
}
154155
}

app/packages/meteor-integration/.babelrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/packages/meteor-integration/main-client.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@ import { Accounts } from 'meteor/accounts-base';
55
import { Meteor } from 'meteor/meteor';
66
import { _ } from 'meteor/underscore';
77
import { print } from 'graphql-tag/printer';
8-
import { Client } from 'subscriptions-transport-ws';
8+
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
99

1010
const defaultNetworkInterfaceConfig = {
1111
path: '/graphql', // default graphql server endpoint
1212
opts: {}, // additional fetch options like `credentials` or `headers`
1313
useMeteorAccounts: true, // if true, send an eventual Meteor login token to identify the current user with every request
1414
batchingInterface: true, // use a BatchingNetworkInterface by default instead of a NetworkInterface
1515
batchInterval: 10, // default batch interval
16+
useSubscription: true, // enable subscription by default
1617
};
1718

18-
const getDefaultWsClient = () => new Client('ws://localhost:8080');
19+
const getDefaultWsClient = () => new SubscriptionClient('ws://localhost:8080', {
20+
reconnect: true,
21+
// connectionParams: {
22+
// // Pass any arguments you want for initialization
23+
// },
24+
});
1925

2026
export const createMeteorNetworkInterface = (givenConfig) => {
2127
const config = _.extend(defaultNetworkInterfaceConfig, givenConfig);
22-
const wsClient = givenConfig && givenConfig.wsClient ? givenConfig.wsClient : getDefaultWsClient();
2328
// absoluteUrl adds a '/', so let's remove it first
2429
let path = config.path;
2530
if (path[0] === '/') {
@@ -30,17 +35,17 @@ export const createMeteorNetworkInterface = (givenConfig) => {
3035
const interfaceToUse = config.batchingInterface ? createBatchingNetworkInterface : createNetworkInterface;
3136

3237
// default interface options
33-
let interfaceOptions = {
38+
const interfaceOptions = {
3439
uri: Meteor.absoluteUrl(path),
3540
};
3641

3742
// if a BatchingNetworkInterface is used with a correct batch interval, add it to the options
38-
if(config.batchingInterface && config.batchInterval) {
43+
if (config.batchingInterface && config.batchInterval) {
3944
interfaceOptions.batchInterval = config.batchInterval;
4045
}
4146

4247
// if 'fetch' has been configured to be called with specific opts, add it to the options
43-
if(!_.isEmpty(config.opts)) {
48+
if (!_.isEmpty(config.opts)) {
4449
interfaceOptions.opts = config.opts;
4550
}
4651

@@ -49,7 +54,6 @@ export const createMeteorNetworkInterface = (givenConfig) => {
4954
if (config.useMeteorAccounts) {
5055
networkInterface.use([{
5156
applyMiddleware(request, next) {
52-
5357
// cookie login token created by meteorhacks:fast-render and caught during server-side rendering by rr:react-router-ssr
5458
const { loginToken: cookieLoginToken } = config;
5559
// Meteor accounts-base login token stored in local storage, only exists client-side
@@ -82,31 +86,24 @@ export const createMeteorNetworkInterface = (givenConfig) => {
8286
}
8387

8488
if (config.useSubscription) {
85-
return _.extend(networkInterface, {
86-
subscribe: (request, handler) => wsClient.subscribe({
87-
query: print(request.query),
88-
variables: request.variables,
89-
}, handler),
90-
unsubscribe: (id) => {
91-
wsClient.unsubscribe(id);
92-
},
93-
});
89+
const wsClient = givenConfig && givenConfig.wsClient ? givenConfig.wsClient : getDefaultWsClient();
90+
return addGraphQLSubscriptions(networkInterface, wsClient);
91+
// return _.extend(networkInterface, {
92+
// subscribe: (request, handler) => wsClient.subscribe({
93+
// query: print(request.query),
94+
// variables: request.variables,
95+
// }, handler),
96+
// unsubscribe: (id) => {
97+
// wsClient.unsubscribe(id);
98+
// },
99+
// });
94100
}
95101
return networkInterface;
96102
};
97103

98104
export const meteorClientConfig = (networkInterfaceConfig) => {
99-
const networkInterface = createMeteorNetworkInterface(networkInterfaceConfig);
100-
let { initialState } = networkInterface;
101-
if(initialState){
102-
// Temporary workaround for bug in AC@0.5.0: https://github.com/apollostack/apollo-client/issues/845
103-
delete initialState.apollo.queries;
104-
delete initialState.apollo.mutations;
105-
}
106-
107105
return {
108-
networkInterface,
109-
initialState,
106+
networkInterface: createMeteorNetworkInterface(networkInterfaceConfig),
110107
ssrMode: Meteor.isServer,
111108

112109
// Default to using Mongo _id, must use _id for queries.

app/packages/meteor-integration/main-server.js

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ export { createMeteorNetworkInterface, meteorClientConfig } from './main-client'
1616
const defaultConfig = {
1717
path: '/graphql',
1818
maxAccountsCacheSizeInMB: 1,
19-
graphiql : Meteor.isDevelopment,
20-
graphiqlPath : '/graphiql',
21-
graphiqlOptions : {
22-
passHeader : "'Authorization': localStorage['Meteor.loginToken']"
19+
graphiql: Meteor.isDevelopment,
20+
graphiqlPath: '/graphiql',
21+
graphiqlOptions: {
22+
passHeader: "'Authorization': localStorage['Meteor.loginToken']"
2323
},
2424
useSubscription: true,
2525
subscriptionPort: 8080,
26-
configServer: (graphQLServer) => {},
26+
configServer: (graphQLServer) => { },
2727
};
2828

2929
const defaultOptions = {
@@ -51,7 +51,7 @@ export const createApolloServer = (givenOptions = {}, givenConfig = {}) => {
5151
// GraphQL endpoint
5252
graphQLServer.use(config.path, bodyParser.json(), graphqlExpress(async (req) => {
5353
let options,
54-
user = null;
54+
user = null;
5555

5656
if (_.isFunction(givenOptions))
5757
options = givenOptions(req);
@@ -75,7 +75,7 @@ export const createApolloServer = (givenOptions = {}, givenConfig = {}) => {
7575

7676
// Get the user from the database
7777
user = await Meteor.users.findOne(
78-
{"services.resume.loginTokens.hashedToken": hashedToken}
78+
{ "services.resume.loginTokens.hashedToken": hashedToken }
7979
);
8080

8181
if (user) {
@@ -95,11 +95,9 @@ export const createApolloServer = (givenOptions = {}, givenConfig = {}) => {
9595

9696
// Start GraphiQL if enabled
9797
if (config.graphiql) {
98-
graphQLServer.use(config.graphiqlPath, graphiqlExpress(_.extend(config.graphiqlOptions, {endpointURL : config.path})));
98+
graphQLServer.use(config.graphiqlPath, graphiqlExpress(_.extend(config.graphiqlOptions, { endpointURL: config.path })));
9999
}
100100

101-
// create http server for subscription
102-
const server = createServer(graphQLServer);
103101

104102
// This binds the specified paths to the Express server running Apollo + GraphiQL
105103
WebApp.connectHandlers.use(Meteor.bindEnvironment(graphQLServer));
@@ -109,13 +107,23 @@ export const createApolloServer = (givenOptions = {}, givenConfig = {}) => {
109107
if (!subscriptionManager) {
110108
throw new Meteor.Error('SubscriptionManager which is mandatory missing.');
111109
}
112-
new SubscriptionServer({
113-
subscriptionManager,
114-
}, server);
115110
try {
111+
// create http server for subscription
112+
// const server = createServer(graphQLServer);
113+
// Create WebSocket listener server
114+
const server = createServer((request, response) => {
115+
response.writeHead(404);
116+
response.end();
117+
});
116118
server.listen(config.subscriptionPort, () => {
117119
console.log('Subscription manager running ' + config.subscriptionPort);
118120
});
121+
const subscriptionServer = new SubscriptionServer({
122+
subscriptionManager,
123+
}, {
124+
server,
125+
path: '/'
126+
});
119127
} catch (e) {
120128
console.log(e);
121129
}

app/packages/meteor-integration/package.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
"homepage": "https://github.com/apollostack/meteor-integration#readme",
2121
"dependencies": {
2222
"apollo-client": "^0.8.4",
23-
"babel": "^6.5.2",
24-
"babel-core": "^6.22.1",
25-
"babel-eslint": "^7.1.1",
26-
"babel-plugin-add-module-exports": "^0.2.1",
27-
"babel-preset-es2015": "^6.22.0",
28-
"babel-preset-stage-2": "^6.22.0",
29-
"body-parser": "^1.15.2",
3023
"express": "^4.14.0",
3124
"graphql": "^0.9.1",
3225
"graphql-server-express": "^0.6.0",

app/packages/react-runtime-additional/react-runtime-additional.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { _ } from 'meteor/underscore';
33

44
const requiredPackages = {
55
'react-router': '^3.0.0',
6-
graphql: '^0.8.2',
6+
graphql: '^0.9.0',
77
};
88

99

app/src/graphql/transport.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { PersistedQueryNetworkInterface } from 'persistgraphql';
2+
3+
4+
// Returns either a standard, fetch-full-query network interface or a
5+
// persisted query network interface (from `extractgql`) depending on
6+
// the configuration within `./config.js.`
7+
export default function getNetworkInterface(apirUrl = '/graphql', headers = {}) {
8+
uri: apiUrl,
9+
opts: {
10+
11+
}
12+
}

0 commit comments

Comments
 (0)