0.0.8 • Published 3 years ago
halo-graphql v0.0.8
halo-graphql
npm install halo-graphql
If you want to incorporate the Halo API into your own GraphQL server you can use the power of GraphQL-Modules. The halo-graphql
NPM package encapsulates the API's type definitions and resolvers to provide a turnkey solution for integrating the Halo API into your app.
- Install
halo-graphql
. Visit Autocode and copy your General Identity Token from here.
On the GraphQL server context create a field called
HALO_AUTOCODE_TOKEN
and assign it the value of your Autocode token.
Simple example
import { ApolloError, ApolloServer } from 'apollo-server-micro';
import { createApplication } from 'graphql-modules';
import HaloGraphQL from 'halo-graphql';
const application = createApplication({
modules: [HaloGraphQL],
});
const schema = application.createSchemaForApollo()
const apolloServer = new ApolloServer({
schema,
formatError: (error: any) => {
return new ApolloError(error.message, error.extensions.code);
},
context: ({ req }) => ({
HALO_AUTOCODE_TOKEN: process.env.HALO_AUTOCODE_TOKEN,
}),
});
export default apolloServer;