Clone This Repo
$ git clone git@github.com:brothergiez/graphql-kafka-subscriptions.git
OpenSSL has been upgraded in High Sierra and homebrew does not overwrite default system libraries. That means when building node-rdkafka, because you are using openssl, you need to tell the linker where to find it:
$ export CPPFLAGS=-I/usr/local/opt/openssl/include
$ export LDFLAGS=-L/usr/local/opt/openssl/lib
Then you can install this project .
$ cd graphql-kafka-subscriptions
$ npm install
before running this project make sure zookeeper service and kafka-server running on your local machine and create topic with name 'sampleTopic'. For installing, running and create kafka topic, you can read this articles https://www.tutorialkart.com/apache-kafka-tutorial/
$ npm run dev
$ npm run ms
Open your browser: http://localhost:3030/graphql
On the tab 1 :
subscription {
transactionCreated {
id
merchant
amount
notes
status
}
}
On the tab 2 :
subscription {
transactionUpdated {
id
merchant
amount
notes
status
}
}
On the tab 3 :
mutation{
createTransaction(
merchant: "GOPAY2",
notes: "Gopay saya2",
amount: 1000
){
id
merchant
amount
status
}
}
For simulating update transaction execute this curl:
curl --request PUT \
--url http://localhost:3000/transaction \
--header 'content-type: application/json' \
--data '{
"channel": "TRX_UPDATED",
"transactionUpdated": {
"id": "[PASTE-ID-FROM-LAST-TRANSACTION]",
"merchant": "GOPAY2",
"amount": 1000,
"notes": "Gopay saya2",
"status": "SUCCESS"
},
"channelId": "T2"
}'