Skip to content

feat: ability to configure request handler #1271

@tusharmath

Description

@tusharmath

Current
We can only setup one request handler in a JS worker file. This proposal intends to break that restriction

Proposal

type schema @upstream(onRequest: "onRequest") {
  # ... 
}

type Query {
  foo: Foo @http(path: "/foo", onRequest: "onRequestFoo")
  bar: Bar @http(path: "/bar", onRequest: "onRequestBar")
  baz: Bar @http(path: "/baz")
}
function onRequest (request) {
  // 
}

function onRequestFoo (request) {
  // 
}

function onRequestBar (request) {
  // 
}

In the above implementation when:

  1. We query foo, onRequestFoo is called with the request params.
  2. We query bar, onRequestBar is called with the request params.
  3. We query baz, onRequest (default handler) is called with the request params.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions