@HttpJsonDataSource

Generates a resolver for a HTTP based Data Source which returns JSON.
Directive Definition
directive @HttpJsonDataSource (
"""
the host of the origin
"""
host: String!
"""
the url of the origin
"""
url: String!
"""
the HTTP method the client should use for the request, defaults to GET
"""
method: HTTP_METHOD = GET
"""
parameters
"""
params: [Parameter]
) on FIELD_DEFINITION

This directive lets you define how to fetch data for the attached field.

Example usage
type Query {
post(id: Int!): JSONPlaceholderPost
@HttpJsonDataSource(
host: "jsonplaceholder.typicode.com"
url: "/posts/{{ .id }}"
params: [
{
name: "id"
sourceKind: FIELD_ARGUMENTS
sourceName: "id"
variableType: "Int!"
}
]
)
}
Example Query
{
post(id: 1) {
id
name
}
}

This query will internally resolve the following URL: https://jsonplaceholder.typicode.com/posts/1

The field argument with name "id" will be used to "render" the url template using golang templating syntax.