Skip to content

Commit cb35f78

Browse files
authored
Merge pull request #32 from aliesesay/alie/add_document_to_component
Add graphql query to add document to a component
2 parents 9615e64 + bd47f2a commit cb35f78

3 files changed

Lines changed: 130 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
This query can be used to add a document to a component
2+
https://developer.atlassian.com/cloud/compass/graphql/#mutations_addDocument
3+
https://developer.atlassian.com/cloud/compass/graphql/#queries_documentationCategories
4+
5+
6+
7+
Replace cloudId, title, url, ComponentID and documentationCategoryId below in the variables section with the cloudId for your site, title and url of your document, componentID of your Compass component and the documentationcategory ID, and execute the query. You can use the GraphQL explorer to run this query and explore the Compass API further.
8+
9+
NB: The addDocument mutation in Compass is an experimental feature, and you need to explicitly opt in by using the @optIn directive.
10+
11+
First, you need to fetch the DocumentationCategoryID for the components.
12+
13+
STEP 1: => Fetch DocumentationCategoryID for the component
14+
15+
##QUERY
16+
17+
18+
```graphql
19+
query fetchDocumentationCategories($cloudId: ID!, $first: Int, $after: String) {
20+
compass {
21+
documentationCategories(cloudId: $cloudId, first: $first, after: $after) @optIn(to: "compass-beta") {
22+
nodes {
23+
id
24+
name
25+
}
26+
edges {
27+
node {
28+
id
29+
name
30+
}
31+
cursor
32+
}
33+
pageInfo {
34+
hasNextPage
35+
endCursor
36+
}
37+
}
38+
}
39+
}
40+
41+
##Query Variables
42+
43+
```graphql
44+
{
45+
"cloudId": "YOUR-CLOUD-ID",
46+
"first": 4,
47+
"after": null
48+
}
49+
50+
51+
From the above result, you will get the Document Category ID in the ARI format for the following types:
52+
53+
Discover
54+
Contributor
55+
Maintainer
56+
Other
57+
58+
Step 2: Use the following query to add a document to your Compass
59+
60+
##QUERY
61+
62+
```graphql
63+
mutation addDocument($input: CompassAddDocumentInput!) {
64+
compass {
65+
addDocument(input: $input) @optIn(to: "compass-beta") {
66+
success
67+
errors {
68+
message
69+
}
70+
documentDetails {
71+
id
72+
title
73+
url
74+
componentId
75+
documentationCategoryId
76+
}
77+
}
78+
}
79+
}
80+
81+
##QUERY VARIABLES
82+
83+
```graphql
84+
{
85+
"input": {
86+
"title": "title",
87+
"url": "your-doc-url",
88+
"componentId": "Your-component-id",
89+
"documentationCategoryId": "your-documentationcateoryid"
90+
}
91+
}
92+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
mutation addDocument($input: CompassAddDocumentInput!) {
2+
compass {
3+
addDocument(input: $input) @optIn(to: "compass-beta") {
4+
success
5+
errors {
6+
message
7+
}
8+
documentDetails {
9+
id
10+
title
11+
url
12+
componentId
13+
documentationCategoryId
14+
}
15+
}
16+
}
17+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
query fetchDocumentationCategories($cloudId: ID!, $first: Int, $after: String) {
2+
compass {
3+
documentationCategories(cloudId: $cloudId, first: $first, after: $after) @optIn(to: "compass-beta") {
4+
nodes {
5+
id
6+
name
7+
}
8+
edges {
9+
node {
10+
id
11+
name
12+
}
13+
cursor
14+
}
15+
pageInfo {
16+
hasNextPage
17+
endCursor
18+
}
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)