跳到主要内容
版本:Next

GraphQL

GraphQL Source 连接器

描述

用于读取GraphQL数据。

主要特性

源选项

名称类型是否必填默认值
urlStringYes-
queryStringYes-
variablesConfigNo-
enable_subscriptionbooleanNofalse
timeoutLongNo-
content_fieldStringYes$.data.{query_object}.*
schema.fieldsConfigYes-
formatStringNojson
paramsMapYes-
poll_interval_millisintNo-
retryintNo-
retry_backoff_multiplier_msintNo100
retry_backoff_max_msintNo10000
enable_multi_linesbooleanNofalse
common-optionsconfigNo-

url [String]

http 请求路径。

query [String]

GraphQL 表达式查询字符串

variables [String]

GraphQL 变量

比如

variables = {
limit = 2
}

enable_subscription [boolean]

  1. true : 构建一个套接字读取器来订阅GraphQL服务
  2. false : 构建GraphQL服务的http阅读器订阅

timeout [Long]

超时时间

content_field [String]

SONPath通配符

params [Map]

HTTP请求参数

poll_interval_millis [int]

流模式下请求HTTP API间隔(毫秒)

retry [int]

如果请求http返回到‘ IOException ’的最大重试次数

retry_backoff_multiplier_ms [int]

如果请求http失败,则重试回退时间(毫秒)倍率

retry_backoff_max_ms [int]

如果http请求失败,最大重试回退时间(毫秒)

format [String]

上游数据的格式,默认为json。

schema [Config]

填写一个固定值

    schema = {
fields {
metric = "map<string, string>"
value = double
time = long
}
}

fields [Config]

上游数据的模式字段

common options

源插件常用参数,请参考 Source Common Options 获取详细信息

示例

Query

source {
GraphQL {
url = "http://192.168.1.103:9081/v1/graphql"
format = "json"
content_field = "$.data.source"
query = """
query MyQuery($limit: Int) {
source(limit: $limit) {
id
val_bool
val_double
val_float
}
}
"""
variables = {
limit = 2
}
schema = {
fields {
id = "int"
val_bool = "boolean"
val_double = "double"
val_float = "float"
}
}
}
}

Subscription

source {
GraphQL {
url = "http://192.168.1.103:9081/v1/graphql"
format = "json"
content_field = "$.data.source"
query = """
query MyQuery($limit: Int) {
source(limit: $limit) {
id
val_bool
val_double
val_float
}
}
"""
variables = {
limit = 2
}
enable_subscription = true
schema = {
fields {
id = "int"
val_bool = "boolean"
val_double = "double"
val_float = "float"
}
}
}
}

变更日志

Change Log
ChangeCommitVersion
[Feature][Connector-V2] Add GraphQL source and sink (#7265)https://github.com/apache/seatunnel/commit/dde6f9fcbd2.3.9