Skip to content

Instantly share code, notes, and snippets.

@asoorm
Created March 22, 2023 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asoorm/32adaa73002ac3a61daaa62d6777dda6 to your computer and use it in GitHub Desktop.
Save asoorm/32adaa73002ac3a61daaa62d6777dda6 to your computer and use it in GitHub Desktop.
Publish a Kafka topic as a GraphQL Subscription declaratively with Tyk's Univeral Data Graph
apiVersion: tyk.tyk.io/v1alpha1
kind: ApiDefinition
metadata:
name: udg-kafka
spec:
name: Universal Data Graph Kafka # name of the API Definition
use_keyless: true # make the api keyless (no security)
active: true # API can be active or inactive
graphql:
enabled: true # enable GraphQL Mode
version: "2" # Tyk GraphQL API Version
execution_mode: # this enables UDG, other options are subGraph, superGraph and proxyOnly
schema: | # the GraphQL schema
type Product {
name: String!
price: Int!
in_stock: Int!
}
type Subscription {
stock(name: String): Product!
}
playground:
enabled: true # enable the GraphQL playground
path: /playground
engine:
field_configs:
- type_name: Subscription
field_name: stock
disable_default_mapping: false
path:
- "stock"
data_sources:
- kind: Kafka
internal: false
name: "kafka-consumer-group"
root_fields:
- type: "Subscription"
fields:
- "stock"
config:
broker_addresses:
- kafka.svc:9092
topics:
- test.topic.{{.arguments.name}}
group_id: test.group
client_id: tyk-kafka-integration-{{.arguments.name}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment