Directive Definitiondirective @GraphQLDataSource ("""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 = POST"""parameters"""params: [Parameter]) on FIELD_DEFINITION
Example usagetype Query {country(code: String!): Country@GraphQLDataSource(host: "countries.trevorblades.com"url: "/"field: "country"params: [{name: "code"sourceKind: FIELD_ARGUMENTSsourceName: "code"variableType: "String!"}])}type Country {code: Stringname: Stringnative: Stringphone: Stringcontinent: Continentcurrency: Stringlanguages: [Language]emoji: StringemojiU: Stringcoordinates: [Coordinates]@HttpJsonDataSource(host: "locationiq.com"url: "/v1/search_sandbox.php?format=json&q={{ .name }}&accept-language=en"params: [{name: "name"sourceKind: OBJECT_VARIABLE_ARGUMENTsourceName: "name"variableType: "String"}])}
Example Query{country(code: "DE") {codename}}
This query will send the following query to the upstream service:
Example Query{country(code: "DE") {codename}}
As you can see in the example, nesting is possible. The "engine" assumes that all fields without a resolver belong to the parent/enclosing data source. Therefore if you nest a field and attach a new @directive this will generate a new resolver.