Teamwork Graph: Calling the API asApp

Hi all,

I have a question regarding support for running teamwork graph API calls as a forge application.

In @forge/api 8.3.0, requestTeamworkGraph is declared on asUser() and not on asApp().

The UI bridge docs explicitly states

Calls always run as the current user - Forge apps can’t call the Teamwork Graph API as the app.

This call is not in the typings, but it seems to work at runtime:

import api, { route } from "@forge/api";
await api.asApp().requestAtlassian(route`/graphql/twg`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ query, variables }),
});

Does anyone know which of these is officially supported for a backend call as the app:

  1. api.asApp().requestTeamworkGraph(...), with the missing type fixed in @forge/api

  2. api.asApp().requestAtlassian(route/graphql/twg, ...), with that path documented

  3. None of the above

If it is only officially supported to be run as the user, is there intention to support running it with api.asApp() in the future?

Hi @janzubac,

The only documented backend path is api.asUser().requestTeamworkGraph(), so I’d go with option 3 until staff weigh in. The bridge page tip tells backend code to call requestTeamworkGraph() from @forge/api with api.asUser(). Your quote is the frontend sentence above it.

In 8.3.0, line 76 of index.d.ts leaves TeamworkGraphFetchMethods out of AsAppFetchMethods, and asApp() in fetch.js has no requestTeamworkGraph. The 8.4.0-next.8 typing is the same.

From next.7 the wrapper also defaults X-Query-Context to the context ARI (changelog entry 2995cbe, fetch.js in next.8). A raw requestAtlassian call won’t send it.

Your call is the same gateway call, made as the app. If it returns real data for you, the gateway isn’t rejecting app calls on that path, but working and supported aren’t the same thing. I haven’t run it live.

The bridge page says the user “must have the Teamwork Graph permissions required by the GraphQL operation being called”. With asUser the results follow that user’s permissions, so an asApp result would probably need its own visibility checks (untested).

Support is staff’s call. CHANGE-3448 is silent on asApp too. For a Marketplace app I’d treat it as unsupported, because the limitations page promises a month of notice before changes to the documented API before GA, and an undocumented path gets none.

Thank you for the detailed answer Mihai! I have reached out to Atlassian regarding the official support question so let’s see what they say regarding that.