@call Directive

The @call directive composes one or more resolver steps into a pipeline. Each step invokes another query or mutation field, passing data forward through the chain.

Fields

FieldTypeDefaultDescription
steps[Step]RequiredAn ordered list of resolver steps to execute.
dedupeBooleanfalseDeduplicate identical composed calls.

Step Fields

FieldTypeDescription
queryStringName of a Query field to invoke.
mutationStringName of a Mutation field to invoke (use query or mutation, not both).
argsJSONArguments passed to the target field. Supports mustache templates.

Example

schema @server(port: 8000) {
  query: Query
}

type Query {
  posts: [Post] @http(url: "https://jsonplaceholder.typicode.com/posts")
  user(id: Int!): User @http(url: "https://jsonplaceholder.typicode.com/users/{{.args.id}}")

  firstPostAuthor: User
  @call(
    steps: [
      { query: "posts" }
      { query: "user", args: { id: "{{.0.userId}}" } }
    ]
  )
}

type Post {
  id: Int!
  userId: Int!
  title: String!
}

type User {
  id: Int!
  name: String!
  email: String!
}

The firstPostAuthor field fetches all posts, then uses the first post’s userId to resolve the corresponding user.