Hi,
Is it possible to use custom entities and complex queries with Forge Remote? I couldn’t find any examples for custom entities in this documentation. If we can use custom entities with Forge Remote, any examples of GraphQL queries would be appreciated.
Thanks.
I haven’t used it myself yet, but custom entities can be used with the appStoredCustomEntities
GraphQL query. I think the only documentation that’s available at the moment is the GraphQL schema itself, which you can view in the GraphQL API explorer (enter appStoredCustomEntities
in the search field of the “Docs” sidebar on the right).
3 Likes
The GraphQL API explorer helped a lot. I was able to successfully create queries for custom entities. Thank you!
If anyone else needs them, here are the queries I used:
Query:
query forge_app_getApplicationStorageCustomEntities(
$contextAri: ID!,
$entityName: String!,
$indexName: String!,
$partition: [AppStoredCustomEntityFieldValue!],
$range: AppStoredCustomEntityRange,
$filters: AppStoredCustomEntityFilters,
$sort: SortOrder,
$cursor: String,
$limit: Int) {
appStoredCustomEntities(
contextAri: $contextAri,
entityName: $entityName,
indexName: $indexName,
partition: $partition,
range: $range,
filters: $filters,
sort: $sort,
cursor: $cursor,
limit: $limit) {
edges {
node {
value
key
}
cursor
}
pageInfo {
hasNextPage
}
}
}
Set:
mutation forge_app_setApplicationStorageCustomEntity($input: SetAppStoredCustomEntityMutationInput!) {
appStorageCustomEntity {
setAppStoredCustomEntity(input: $input) {
success
errors {
message
extensions {
errorType
statusCode
}
}
}
}
}
Get:
query forge_app_getApplicationStorageCustomEntity($contextAri: ID!, $entityName: String!, $key: ID!) {
appStoredCustomEntity(
contextAri: $contextAri,
entityName: $entityName,
key: $key
) {
value
}
}
Delete:
mutation forge_app_deleteApplicationStorageCustomEntity($input: DeleteAppStoredCustomEntityMutationInput!) {
appStorageCustomEntity {
deleteAppStoredCustomEntity(input: $input) {
success
errors {
message
extensions {
errorType
statusCode
}
}
}
}
}
5 Likes
@Berkayztrk is Forge remote even working for you? I can’t get it to work
I can confirm, that GraphQL API works with the Forge Remote token. Need to past the system token to the client like this:
const client = new GraphQLClient('https://api.atlassian.com/graphql', {
headers: {
Authorization: `Bearer ${tokens.systemToken}`,
},
});
const variables = {
contextAri: tokens.siteAri,
entityName: `${enitity_name}`,
key: `${enitity_id}`,
};
const response = await client.request(appStoredCustomEntity, variables);