mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 17:41:43 -05:00
Merge branch 'apollo2-merge-devel' of https://github.com/lbke/Vulcan into apollo2
This commit is contained in:
commit
d318c69c96
8 changed files with 25 additions and 22 deletions
|
@ -3,7 +3,8 @@ import {ApolloLink} from 'apollo-link';
|
||||||
import watchedMutationLink from './links/watchedMutation';
|
import watchedMutationLink from './links/watchedMutation';
|
||||||
import httpLink from './links/http';
|
import httpLink from './links/http';
|
||||||
import meteorAccountsLink from './links/meteor';
|
import meteorAccountsLink from './links/meteor';
|
||||||
import {createStateLink, errorLink} from '../../modules/apollo-common';
|
import errorLink from './links/error';
|
||||||
|
import {createStateLink} from '../../modules/apollo-common';
|
||||||
import cache from './cache';
|
import cache from './cache';
|
||||||
|
|
||||||
// these links do not change once created
|
// these links do not change once created
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
export * from './links/state';
|
export * from './links/state';
|
||||||
export {default as errorLink} from './links/error';
|
|
||||||
|
|
|
@ -30,7 +30,10 @@ import {enableSSR} from '../apollo-ssr';
|
||||||
|
|
||||||
import universalCookiesMiddleware from 'universal-cookie-express';
|
import universalCookiesMiddleware from 'universal-cookie-express';
|
||||||
|
|
||||||
import { getApolloApplyMiddlewareOptions, getApolloServerOptions } from './settings';
|
import {
|
||||||
|
getApolloApplyMiddlewareOptions,
|
||||||
|
getApolloServerOptions,
|
||||||
|
} from './settings';
|
||||||
|
|
||||||
import {getSetting} from '../../modules/settings.js';
|
import {getSetting} from '../../modules/settings.js';
|
||||||
import {formatError} from 'apollo-errors';
|
import {formatError} from 'apollo-errors';
|
||||||
|
@ -44,9 +47,8 @@ import {formatError} from 'apollo-errors';
|
||||||
const createApolloServer = ({
|
const createApolloServer = ({
|
||||||
apolloServerOptions = {}, // apollo options
|
apolloServerOptions = {}, // apollo options
|
||||||
config = {}, // Vulcan options
|
config = {}, // Vulcan options
|
||||||
apolloApplyMiddlewareOptions // apollo.applyMiddleware,
|
apolloApplyMiddlewareOptions, // apollo.applyMiddleware,
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
const initialContext = initContext(apolloServerOptions.context);
|
const initialContext = initContext(apolloServerOptions.context);
|
||||||
|
|
||||||
// this replace the previous syntax graphqlExpress(async req => { ... })
|
// this replace the previous syntax graphqlExpress(async req => { ... })
|
||||||
|
@ -84,7 +86,7 @@ const createApolloServer = ({
|
||||||
app: WebApp.connectHandlers,
|
app: WebApp.connectHandlers,
|
||||||
path: config.path,
|
path: config.path,
|
||||||
// @see https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#Parameters-2
|
// @see https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#Parameters-2
|
||||||
...apolloApplyMiddlewareOptions
|
...apolloApplyMiddlewareOptions,
|
||||||
});
|
});
|
||||||
|
|
||||||
// setup the end point
|
// setup the end point
|
||||||
|
@ -147,7 +149,7 @@ Meteor.startup(() => {
|
||||||
config: {
|
config: {
|
||||||
path: '/graphql',
|
path: '/graphql',
|
||||||
maxAccountsCacheSizeInMB: 1,
|
maxAccountsCacheSizeInMB: 1,
|
||||||
configServer: apolloServer => { },
|
configServer: apolloServer => {},
|
||||||
voyagerPath: '/graphql-voyager',
|
voyagerPath: '/graphql-voyager',
|
||||||
graphiqlPath: '/graphiql',
|
graphiqlPath: '/graphiql',
|
||||||
// customConfigFromReq
|
// customConfigFromReq
|
||||||
|
@ -157,9 +159,9 @@ Meteor.startup(() => {
|
||||||
formatError,
|
formatError,
|
||||||
tracing: getSetting('apolloTracing', Meteor.isDevelopment),
|
tracing: getSetting('apolloTracing', Meteor.isDevelopment),
|
||||||
cacheControl: true,
|
cacheControl: true,
|
||||||
...getApolloServerOptions()
|
...getApolloServerOptions(),
|
||||||
},
|
},
|
||||||
apolloApplyMiddlewareOptions: getApolloApplyMiddlewareOptions()
|
apolloApplyMiddlewareOptions: getApolloApplyMiddlewareOptions(),
|
||||||
// config: ....
|
// config: ....
|
||||||
// contextFromReq: ....
|
// contextFromReq: ....
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export * from './apollo_server2';
|
export * from './apollo_server2';
|
||||||
export * from './settings';
|
export * from './settings';
|
||||||
|
|
|
@ -12,19 +12,20 @@ import _merge from 'lodash/merge';
|
||||||
//);
|
//);
|
||||||
// registerSetting('apolloServer.jsonParserOptions.limit', undefined, 'DEPRECATED bodyParser jsonParser limit');
|
// registerSetting('apolloServer.jsonParserOptions.limit', undefined, 'DEPRECATED bodyParser jsonParser limit');
|
||||||
|
|
||||||
// NOTE: some option can be functions, so they cannot be
|
// NOTE: some option can be functions, so they cannot be
|
||||||
// defined as Meteor settings, which are pure JSON (no function)
|
// defined as Meteor settings, which are pure JSON (no function)
|
||||||
|
|
||||||
// @see https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#constructor-options-lt-ApolloServer-gt
|
// @see https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#constructor-options-lt-ApolloServer-gt
|
||||||
let apolloServerOptions = { };
|
let apolloServerOptions = {};
|
||||||
export const registerApolloServerOptions = (options) => {
|
export const registerApolloServerOptions = options => {
|
||||||
apolloServerOptions = _merge(apolloServerOptions, options);
|
apolloServerOptions = _merge(apolloServerOptions, options);
|
||||||
};
|
};
|
||||||
export const getApolloServerOptions = () => apolloServerOptions;
|
export const getApolloServerOptions = () => apolloServerOptions;
|
||||||
|
|
||||||
// @see https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#Parameters-2
|
// @see https://www.apollographql.com/docs/apollo-server/api/apollo-server.html#Parameters-2
|
||||||
let apolloApplyMiddlewareOptions = { };
|
let apolloApplyMiddlewareOptions = {};
|
||||||
export const registerApolloApplyMiddlewareOptions = (options) => {
|
export const registerApolloApplyMiddlewareOptions = options => {
|
||||||
apolloApplyMiddlewareOptions = _merge(apolloApplyMiddlewareOptions, options);
|
apolloApplyMiddlewareOptions = _merge(apolloApplyMiddlewareOptions, options);
|
||||||
};
|
};
|
||||||
export const getApolloApplyMiddlewareOptions = () => apolloApplyMiddlewareOptions;
|
export const getApolloApplyMiddlewareOptions = () =>
|
||||||
|
apolloApplyMiddlewareOptions;
|
||||||
|
|
|
@ -11,7 +11,7 @@ import {InMemoryCache} from 'apollo-cache-inmemory';
|
||||||
import {SchemaLink} from 'apollo-link-schema';
|
import {SchemaLink} from 'apollo-link-schema';
|
||||||
import {GraphQLSchema} from '../../modules/graphql.js';
|
import {GraphQLSchema} from '../../modules/graphql.js';
|
||||||
|
|
||||||
import {createStateLink, errorLink} from '../../modules/apollo-common';
|
import {createStateLink} from '../../modules/apollo-common';
|
||||||
import {ApolloLink} from 'apollo-link';
|
import {ApolloLink} from 'apollo-link';
|
||||||
|
|
||||||
// @see https://www.apollographql.com/docs/react/features/server-side-rendering.html#local-queries
|
// @see https://www.apollographql.com/docs/react/features/server-side-rendering.html#local-queries
|
||||||
|
@ -30,7 +30,7 @@ export const createClient = async ({req, computeContext}) => {
|
||||||
const schemaLink = new SchemaLink({schema, context});
|
const schemaLink = new SchemaLink({schema, context});
|
||||||
const client = new ApolloClient({
|
const client = new ApolloClient({
|
||||||
ssrMode: true,
|
ssrMode: true,
|
||||||
link: ApolloLink.from([stateLink, errorLink, schemaLink]),
|
link: ApolloLink.from([stateLink, schemaLink]),
|
||||||
// @see https://www.apollographql.com/docs/react/features/server-side-rendering.html#local-queries
|
// @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
|
// 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
|
// API server, so we need to ensure it isn't firewalled, etc
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// see https://github.com/apollographql/graphql-tools/blob/master/docs/source/schema-directives.md#marking-strings-for-internationalization
|
// see https://github.com/apollographql/graphql-tools/blob/master/docs/source/schema-directives.md#marking-strings-for-internationalization
|
||||||
|
|
||||||
import {addGraphQLDirective, addGraphQLSchema} from '../modules/graphql';
|
import {addGraphQLDirective, addGraphQLSchema} from '../modules/graphql';
|
||||||
import {SchemaDirectiveVisitor} from 'apollo-server';
|
import {SchemaDirectiveVisitor} from 'graphql-tools';
|
||||||
import {defaultFieldResolver} from 'graphql';
|
import {defaultFieldResolver} from 'graphql';
|
||||||
import {Collections} from '../modules/collections';
|
import {Collections} from '../modules/collections';
|
||||||
import {getSetting} from '../modules/settings';
|
import {getSetting} from '../modules/settings';
|
||||||
|
@ -79,7 +79,7 @@ Migration function
|
||||||
const migrateIntlFields = async defaultLocale => {
|
const migrateIntlFields = async defaultLocale => {
|
||||||
if (!defaultLocale) {
|
if (!defaultLocale) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Please pass the id of the locale to which to migrate your current content (e.g. migrateIntlFields('en'))"
|
'Please pass the id of the locale to which to migrate your current content (e.g. migrateIntlFields(\'en\'))'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue