0.0.8 • Published 2 years ago

halo-graphql v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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.

  1. Install halo-graphql.
  2. Visit Autocode and copy your General Identity Token from here.

  3. On the GraphQL server context create a field called HALO_AUTOCODE_TOKEN and assign it the value of your Autocode token.

View full example code here.

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;