Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: @custom directive to make batch requests to services that accept them #8950

Open
damonfeldman opened this issue Aug 11, 2023 · 0 comments
Labels
kind/feature Something completely new we should consider.

Comments

@damonfeldman
Copy link

Use case

A custom query may be invoked in a chatty way for large GraphQL requests. E.g.

type User {
username: String! @id
...
posts: [Post] @Custom(http: {
url: "https://my.api.com/person/$username/posts",
method: GET
})
}

and a query
queryUser (first: 10) {
posts
}

will make 10 requests, one for each username of the first 10 users. This could sometimes be served by a single request that accepts an array of 10 usernames (for apis that accept that).

Links to Discuss, RFC or previous Issues and PRs

No response

Links to examples and research

No response

Current state

No response

Solution proposal

Each API will be different in how it accepts a batch of data, so some expression syntax will be needed for this to work.

batchUrl: https://my.api.com/person/posts?usernames=[$username] // where $username is expanded to an array of all usernames

It would be ideal to specify how to do this. One way would be to interpret "batchUrl" as a pre-fetch syntax that defines how to get all data and put it in a map keyed by the fetch parameter, which is then used as needed in building the GraphQL result.

It is unclear the best way to accomplish this right now.

Additional Information

No response

@damonfeldman damonfeldman added the kind/feature Something completely new we should consider. label Aug 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Something completely new we should consider.
Development

No branches or pull requests

1 participant