2.0.0 • Published 2 years ago
@neo4j/graphql-amqp-subscriptions-engine v2.0.0
@neo4j/graphql-amqp-subscriptions-engine
Subscription plugin for @neo4j/graphql, currently supporting AMQP 0-9-1 brokers such as:
- RabbitMQ
- Apache Qpid
- Apache ActiveMQ
Installation
npm install @neo4j/graphql-amqp-subscriptions-engineUsage
const { Neo4jGraphQLAMQPSubscriptionsEngine } = require("@neo4j/graphql-amqp-subscriptions-engine");
const plugin = new Neo4jGraphQLAMQPSubscriptionsEngine({
connection: {
hostname: "localhost",
username: "guest",
password: "guest",
},
});
const neoSchema = new Neo4jGraphQL({
typeDefs,
driver,
plugins: {
subscriptions: plugin,
},
});To close the connection with RabbitMQ:
await plugin.close();Options
The following options are available in the plugin.
- connection: AMQP connection options or amqp url (e.g.
amqp://localhost). - exchange: (optional) Queue exchange, defaults to
neo4j.graphql.subscriptions.fx. - reconnectTimeout: (optional) Timeout (in ms) between reconnection attempts. If not set, the plugin will not reconnect. Note that if the first connection fails, it will not attempt to reconnect.
- log: (optional) Enable AMQP logs, defaults to
true. - amqpVersion: (optional) AMQP version to use, only
0-9-1supported at the moment.
Running tests
yarn testto run unit testsyarn test:e2eto run integration tests. These tests require a RabbitMQ instance running, and are not run by default- Use
docker-compose up rabbitmqto spin up a RabbitMQ container for testing - Use
docker-compose up qpidto spin up a Qpid container for testing
- Use