0.6.9 • Published 3 years ago

@financial-times/tc-api-graphql v0.6.9

Weekly downloads
69
License
ISC
Repository
github
Last release
3 years ago

@financial-times/tc-api-graphql

Treecreeper&tm; graphql express middleware to sit in front of a neo4j database instance

It exports {getGraphqlApi}. getGraphqlApi accepts the following configuration object (defaults are as specified below):

API

getGraphqlApi(options)

Sets up a GraphQL api which (if tc-schema-sdk is configured to update on demand) hot reloads the GraphQL schema to match changes to the underlying treecreeper schema. It returns an object with 3 properties

{
  graphqlHandler, // express middleware that implements the GraphQL API
  isSchemaUpdating, // a function that returns a boolean indicating whether the application is successfully keeping the schema that defines its data types up to date
  listenForSchemaChanges, // a function that, when called, starts the api polling for changes to a treecreeper schema published to some url
};

Options

documentStore

An optional reference to a tc-api-s3-document-store instance (or a library implementing the same API), used to store large properties outside the neo4j instance

republishSchema

A boolean indicating whether the application needs to republish the schema to somewhere once it has updated the graphqlApi. Note that republishing depends on a TREECREEPER_SCHEMA_BUCKET environment variable, which should be the name of an s3 bucket.

republishSchemaPrefix = 'api'

If the application needs to republish the schema to somewhere once it has updated the graphqlApi, this string indicates the prefix to use

typeDefs

An optional array value for extending the existing type definitions

{
  typeDefs: [
    `type ExtendedType {
      code: String
      someString: String
      someFloat: Float
      someEnum: AnEnum
    }`,
    `extend type MainType {
      extended: ExtendedType @neo4j_ignore *
    }`,
  ],
}

* @neo4j_ignore must be added so that it is not used during the schema augmentation process

resolvers

An optional object value for adding extra/custom resolvers

{
  resolvers: {
    MainType: {
      extended: () => { ...custom resolver },
    },
  },
}

excludeTypes

An optional array of type names to exclude from neo4j-graphql-js augmentation. This should list all types which get data from sources other than the neo4j

Example

const express = require('express');
const { getGraphqlApi } = require('@financial-times/tc-api-graphql');

const app = express();
const { graphqlHandler, listenForSchemaChanges } = getGraphqlApi();

listenForSchemaChanges();
app.use('/graphql', graphqlHandler);

const PORT = process.env.PORT || 8888;

app.listen(PORT, () => {
	console.log(`Listening on ${PORT}`);
});
0.6.9

3 years ago

0.6.7

3 years ago

0.6.8

3 years ago

0.6.6

3 years ago

0.6.5

3 years ago

0.6.5-beta.1

3 years ago

0.6.4

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0-beta.0

3 years ago

0.5.35

3 years ago

0.5.34

3 years ago

0.5.34-beta.2

3 years ago

0.5.33-beta.1

3 years ago

0.5.32

3 years ago

0.5.33

3 years ago

0.5.30

3 years ago

0.5.32-beta.1

3 years ago

0.5.31

3 years ago

0.5.29

3 years ago

0.5.28

3 years ago

0.5.27

4 years ago

0.5.26

4 years ago

0.5.26-beta.1

4 years ago

0.5.25

4 years ago

0.5.24

4 years ago

0.5.23

4 years ago

0.5.22

4 years ago

0.5.21

4 years ago

0.5.20

4 years ago

0.5.18

4 years ago

0.5.16

4 years ago

0.5.17

4 years ago

0.5.15

4 years ago

0.5.13

4 years ago

0.5.12

4 years ago

0.5.11

4 years ago

0.5.10

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago

0.4.9

4 years ago

0.4.8

4 years ago

0.4.10-beta.1

4 years ago

0.4.7

4 years ago

0.4.6

4 years ago

0.4.5

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.4.0-beta.3

4 years ago

0.4.0-beta.2

4 years ago

0.4.0-beta.1

4 years ago

0.3.11

4 years ago

0.3.10

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.6

4 years ago

0.3.7

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0-beta.14

4 years ago

0.3.0-beta.13

4 years ago

0.3.0-beta.12

4 years ago

0.3.0

4 years ago

0.3.0-beta.11

4 years ago

0.3.0-beta.10

4 years ago

0.3.0-beta.8

4 years ago

0.3.0-beta.9

4 years ago

0.3.0-beta.5

4 years ago

0.3.0-beta.3

4 years ago

0.3.0-beta.4

4 years ago

0.3.0-beta.2

4 years ago

0.3.0-beta.1

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.2-beta.6

4 years ago

0.1.2-beta.5

4 years ago

0.1.2-beta.2

4 years ago

0.1.2-beta.3

4 years ago

0.1.2-beta.1

4 years ago

0.1.2-beta.4

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago