-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add graphql query to add document to a component #32
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
This query can be used to add a document to a component | ||
https://developer.atlassian.com/cloud/compass/graphql/#mutations_addDocument | ||
https://developer.atlassian.com/cloud/compass/graphql/#queries_documentationCategories | ||
|
||
|
||
|
||
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. | ||
|
||
NB: The addDocument mutation in Compass is an experimental feature, and you need to explicitly opt in by using the @optIn directive. | ||
|
||
First, you need to fetch the DocumentationCategoryID for the components. | ||
|
||
STEP 1: => Fetch DocumentationCategoryID for the component | ||
|
||
##QUERY | ||
|
||
|
||
```graphql | ||
query fetchDocumentationCategories($cloudId: ID!, $first: Int, $after: String) { | ||
compass { | ||
documentationCategories(cloudId: $cloudId, first: $first, after: $after) @optIn(to: "compass-beta") { | ||
nodes { | ||
id | ||
name | ||
} | ||
edges { | ||
node { | ||
id | ||
name | ||
} | ||
cursor | ||
} | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
} | ||
} | ||
} | ||
|
||
##Query Variables | ||
|
||
```graphql | ||
{ | ||
"cloudId": "YOUR-CLOUD-ID", | ||
"first": 10, | ||
"after": null | ||
} | ||
|
||
|
||
From the above result, you will get the Document Category ID in the ARI format for the following types: | ||
|
||
Discover | ||
Contributor | ||
Maintainer | ||
Other | ||
|
||
Step 2: Use the following query to add a document to your Compass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Should be "Use the following mutation ... " |
||
|
||
##QUERY | ||
|
||
```graphql | ||
mutation addDocument($input: CompassAddDocumentInput!) { | ||
compass { | ||
addDocument(input: $input) @optIn(to: "compass-beta") { | ||
success | ||
errors { | ||
message | ||
} | ||
documentDetails { | ||
id | ||
title | ||
url | ||
componentId | ||
documentationCategoryId | ||
} | ||
} | ||
} | ||
} | ||
|
||
##QUERY VARIABLES | ||
|
||
```graphql | ||
{ | ||
"input": { | ||
"title": "title", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be worth calling out (in a comment or further above in the readme) that title is optional and you can just supply a url? |
||
"url": "your-doc-url", | ||
"componentId": "Your-component-id", | ||
"documentationCategoryId": "your-documentationcateoryid" | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
mutation addDocument($input: CompassAddDocumentInput!) { | ||
compass { | ||
addDocument(input: $input) @optIn(to: "compass-beta") { | ||
success | ||
errors { | ||
message | ||
} | ||
documentDetails { | ||
id | ||
title | ||
url | ||
componentId | ||
documentationCategoryId | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
query fetchDocumentationCategories($cloudId: ID!, $first: Int, $after: String) { | ||
compass { | ||
documentationCategories(cloudId: $cloudId, first: $first, after: $after) @optIn(to: "compass-beta") { | ||
nodes { | ||
id | ||
name | ||
} | ||
edges { | ||
node { | ||
id | ||
name | ||
} | ||
cursor | ||
} | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: you could limit this to just 4 as right now the categories are static so you won't ever get back more than that for a given site.