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, '...');
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.