Open
Description
We have some special APIs with multiple token types. In GraphQL ones, we use Apollo Client and it has this feature:
new ApolloClient({
link: setContext(async (operation, context) => ({
headers: {
Authorization: await getTokenUtil(context.tokenType), // <--- See here
...context.headers,
},
})),
// ...
})
And the user can send the context
per query/mutation:
apolloClient.query({
query: gql`...`,
context: { tokenType: X }, // <--- See here
})
But in REST ones that we use OpenAPI and this useful tool (openapi-typescript-codegen), we can't send any data from query-executor to the client or request
:
openapi --input ./spec.json --output ./generated --name AppClient
const appClient = new AppClient({
// The `options` pararmeter here, is hard-coded in the generated codes
// (including `{method, url, query, errors}`):
TOKEN: async (options: ApiRequestOptions) => await getTokenUtil(/* ??? */),
});
// THIS METHOD DOESN'T ACCEPT ANY EXTRA DATA (except query parameters):
const response = await appClient.organizations.createOrganization({
name: 'OrgName',
description: 'OrgDescription',
})
Metadata
Metadata
Assignees
Labels
No labels