DEPRECATED. Please use fusion-plugin-apollo instead
This plugin connects GraphQL schema to your Fusion.js server, allowing you to host a web server and graphql endpoint within the same Fusion.js project. This is most useful when used with fusion-apollo and fusion-apollo-universal-client.
yarn add fusion-plugin-apollo-server
To use the apollo server create a schema. The schema can be provided using the GraphQLSchemaToken from fusion-apollo. See the Apollo Documentation for how to generate a schema.
import ApolloServer, {ApolloServerEndpointToken} from 'fusion-plugin-apollo-server';
import {GraphQLSchemaToken} from 'fusion-apollo';
import {makeExecutableSchema} from 'graphql-tools';
export default () => {
...
app.register(ApolloServer);
app.register(ApolloServerEndpointToken, '/graphql'); // optional - /graphql is the default
app.register(GraphQLSchemaToken, makeExecutableSchema(...));
...
};
import {ApolloServerEndpointToken} from 'fusion-plugin-apollo-server';
This should be registered to a string representing the desired GraphQL endpoint. If using fusion-apollo-universal-client, this will likely be the same value as `ApolloClientEndpointToken.
import {ApolloServerFormatFunctionToken} from 'fusion-plugin-apollo-server';
Register function to format errors from resolvers. Could be used for logging.
This can be used to transform the koa context into an apollo context.
import {ApolloContextToken} from 'fusion-apollo';
app.register(ApolloContextToken, ctx => {
return {
httpContext: ctx,
otherContext: SOMEOHTERCONTEXT
};
});