Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@financial-times/tc-api-graphql

Package Overview
Dependencies
Maintainers
18
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@financial-times/tc-api-graphql

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

  • 0.6.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
205
increased by2462.5%
Maintainers
18
Weekly downloads
 
Created
Source

@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}`);
});

FAQs

Package last updated on 24 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc