mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 09:31:43 -05:00
try to load the schema
This commit is contained in:
parent
7b9fc71cf7
commit
e95098dced
3 changed files with 72 additions and 20 deletions
49
package-lock.json
generated
49
package-lock.json
generated
|
@ -705,6 +705,14 @@
|
|||
"apollo-link": "^1.2.3"
|
||||
}
|
||||
},
|
||||
"apollo-link-schema": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/apollo-link-schema/-/apollo-link-schema-1.1.1.tgz",
|
||||
"integrity": "sha512-zlyt9jlHMK+vwW7jPPetR5oHI/gIdbLmExqVCjJm8xx7KEdP9xKBCy13Zd6r0EYE9tNt5ygWohne6WYtdXBtWQ==",
|
||||
"requires": {
|
||||
"apollo-link": "^1.2.3"
|
||||
}
|
||||
},
|
||||
"apollo-link-state": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/apollo-link-state/-/apollo-link-state-0.4.2.tgz",
|
||||
|
@ -6556,6 +6564,47 @@
|
|||
"requires": {
|
||||
"inherits": "~2.0.1",
|
||||
"readable-stream": "^2.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
||||
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
|
||||
}
|
||||
}
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
"apollo-client": "^2.4.2",
|
||||
"apollo-engine": "^0.5.4",
|
||||
"apollo-errors": "^1.4.0",
|
||||
"apollo-link-schema": "^1.1.1",
|
||||
"apollo-link-state": "^0.4.2",
|
||||
"apollo-server": "^2.1.0",
|
||||
"apollo-server-express": "^2.1.0",
|
||||
|
|
|
@ -7,36 +7,38 @@
|
|||
|
||||
|
||||
import { ApolloClient } from 'apollo-client';
|
||||
import { createHttpLink } from 'apollo-link-http';
|
||||
import fetch from 'node-fetch'
|
||||
import { InMemoryCache } from 'apollo-cache-inmemory';
|
||||
|
||||
// Alternative that does not send real HTTP queries
|
||||
// @see https://www.apollographql.com/docs/react/features/server-side-rendering.html#local-queries
|
||||
// import { SchemaLink } from 'apollo-link-schema';
|
||||
// import schema from "???"
|
||||
import { SchemaLink } from 'apollo-link-schema';
|
||||
// TODO: how to import the schema?
|
||||
import { GraphQLSchema } from '../../modules/graphql'
|
||||
const schema = {} // TODO ???
|
||||
|
||||
// @see https://www.apollographql.com/docs/react/features/server-side-rendering.html#local-queries
|
||||
// import { createHttpLink } from 'apollo-link-http';
|
||||
// import fetch from 'node-fetch'
|
||||
|
||||
const createClient = (req) => {
|
||||
const client = new ApolloClient({
|
||||
ssrMode: true,
|
||||
link: new SchemaLink({ schema }),
|
||||
|
||||
// @see https://www.apollographql.com/docs/react/features/server-side-rendering.html#local-queries
|
||||
// Remember that this is the interface the SSR server will use to connect to the
|
||||
// API server, so we need to ensure it isn't firewalled, etc
|
||||
link: createHttpLink({
|
||||
uri: 'http://localhost:3000',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
// NOTE: this is a Connect req, not an Express req,
|
||||
// so req.header is not defined
|
||||
// cookie: req.header('Cookie'),
|
||||
cookie: req.headers['cookie'],
|
||||
},
|
||||
// need to explicitely pass fetch server side
|
||||
fetch
|
||||
}),
|
||||
//link: createHttpLink({
|
||||
// uri: 'http://localhost:3000',
|
||||
// credentials: 'same-origin',
|
||||
// headers: {
|
||||
// // NOTE: this is a Connect req, not an Express req,
|
||||
// // so req.header is not defined
|
||||
// // cookie: req.header('Cookie'),
|
||||
// cookie: req.headers['cookie'],
|
||||
// },
|
||||
// // need to explicitely pass fetch server side
|
||||
// fetch
|
||||
//}),
|
||||
|
||||
// Alternative that does not send real HTTP queries
|
||||
// link: new SchemaLink({ schema }),
|
||||
|
||||
cache: new InMemoryCache(),
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue