Skip to content

Commit 82600b6

Browse files
committed
docs: Correct GraphQL mutation capabilities and add official guidance section
- Correct misconception that GraphQL cannot create/modify content - Add GraphQL mutation examples (createPage, updatePage, deletePage) - Add Official Guidance section documenting lack of explicit Atlassian guidance - Add practical considerations for choosing between GraphQL and REST APIs - Document beta status and performance considerations from community discussions
1 parent 287b75e commit 82600b6

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

pages/Atlassian___Confluence___API___Concept___GraphQL vs REST.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tags:: [[Diataxis/Explanation]]
1313
- ## Key Principles
1414
- **Query Efficiency**: GraphQL enables fetching multiple related resources in a single request, while REST typically requires multiple endpoint calls
1515
- **Data Control**: GraphQL clients specify exactly what fields they need, reducing over-fetching of unnecessary data
16+
- **Write Operations**: Both APIs support CRUD operations, but with different approaches. GraphQL provides mutations like `createPage`, `updatePage`, and `deletePage` for content management. REST provides comprehensive endpoints including dedicated operations like copying pages (`POST /wiki/rest/api/content/{id}/copy`) that don't have direct GraphQL equivalents
1617
- **Schema Evolution**: GraphQL uses continuous schema evolution with beta fields and deprecation periods, while REST relies on explicit versioning (v1, v2)
1718
- **Flexibility vs Stability**: REST provides stable, versioned endpoints with predictable behavior, while GraphQL offers flexibility but may change more frequently
1819
- **Tooling Maturity**: REST benefits from extensive tooling and community support, while GraphQL provides newer tools like GraphQL Explorer for query discovery
@@ -24,8 +25,9 @@ tags:: [[Diataxis/Explanation]]
2425
- Versioning handled through URL paths (`/api/v1/`, `/api/v2/`)
2526
- Authentication via OAuth 2.0 or Basic auth
2627
- **GraphQL API Approach**:
27-
- Single endpoint for all queries (typically `/graphql`)
28+
- Single endpoint for all queries and mutations (typically `/graphql`)
2829
- Clients send queries specifying exact fields and relationships needed
30+
- Mutations available for creating, updating, and deleting content (e.g., `createPage`, `updatePage`, `deletePage`)
2931
- Query language allows nested data fetching in one request
3032
- Schema introspection enables self-documenting APIs
3133
- Authentication via OAuth 2.0 or JWT for cloud apps
@@ -48,11 +50,51 @@ tags:: [[Diataxis/Explanation]]
4850
}
4951
~~~
5052
- Result: One request fetching only the specified fields
53+
- **GraphQL Mutation Example**: Creating a new page:
54+
~~~
55+
mutation {
56+
confluence {
57+
createPage(input: {
58+
spaceId: "123"
59+
title: "New Page"
60+
body: {storage: {value: "Content here", representation: STORAGE}}
61+
}) {
62+
page {
63+
id
64+
title
65+
}
66+
}
67+
}
68+
}
69+
~~~
70+
- Result: Single mutation request to create and return the new page
71+
- **Duplicating Pages**: While both APIs can duplicate pages, REST provides a dedicated copy endpoint (`POST /wiki/rest/api/content/{id}/copy`), while GraphQL requires fetching the original page content via query, then creating a new page via mutation
5172
- **Performance Trade-off**: While GraphQL can reduce request count, it may take longer for complex queries compared to optimized REST v2 endpoints in some scenarios
73+
- ## Official Guidance
74+
- **Atlassian has not provided explicit, comprehensive guidance** on when to choose GraphQL vs REST APIs for Confluence
75+
- Documentation focuses on describing capabilities rather than prescribing when to use each API
76+
- Developers must evaluate both APIs based on their specific use cases and requirements
77+
- **Considerations for Choosing**:
78+
- **Use REST API** when:
79+
- You need mature, stable, well-documented interfaces
80+
- Your use case requires specialized operations (e.g., direct page copying)
81+
- You prioritize maximum feature coverage and tooling support
82+
- You have existing REST integrations or team familiarity with REST
83+
- **Consider GraphQL API** when:
84+
- You need efficient data retrieval with related entities in single queries
85+
- You want to minimize over-fetching and reduce request count
86+
- You can work with evolving APIs (GraphQL was in beta as of March 2022)
87+
- Your use case benefits from schema introspection and strongly-typed queries
88+
- **Performance Note**: Community testing has shown REST v1 may outperform GraphQL and REST v2 in some scenarios, suggesting performance evaluation is use-case specific
89+
- **Beta Status**: GraphQL APIs were released in beta as of March 2022, emphasizing that they are still evolving and subject to change based on user feedback
90+
- **Deprecation Concerns**: Developer community discussions have raised concerns about REST v1 deprecation and the readiness of newer APIs to fully replace older versions
91+
- See also: [Confluence GraphQL API Documentation](https://developer.atlassian.com/cloud/confluence/graphql/), [Community Performance Discussion](https://community.developer.atlassian.com/t/performance-rest-vs-graphql/69254)
5292
- ## Misconceptions
5393
- GraphQL is always faster than REST → **False**. Performance depends on query complexity and server implementation. Some GraphQL queries may be slower than equivalent REST calls
94+
- GraphQL cannot create or modify content → **False**. GraphQL provides mutations like `createPage`, `updatePage`, and `deletePage` for content management operations. Both APIs support write operations, though REST may offer more specialized endpoints (like direct page copying)
95+
- GraphQL can do everything REST can do → **Partially false**. While GraphQL has mutations for CRUD operations, REST may have specialized endpoints that don't have direct GraphQL equivalents (e.g., dedicated copy endpoints). For duplicating pages, REST's copy endpoint is more straightforward than GraphQL's query-then-create approach
5496
- REST v2 is just an updated version of v1 → **False**. REST v2 was redesigned for performance and removed expansions, requiring a different approach to data retrieval
55-
- GraphQL eliminates the need for REST → **False**. Both APIs serve different purposes. REST may be simpler for straightforward CRUD operations, while GraphQL excels at complex nested data retrieval
97+
- GraphQL eliminates the need for REST → **False**. Both APIs serve different purposes. REST may have specialized operations and better tooling for certain workflows, while GraphQL excels at complex nested data retrieval and provides a unified interface for queries and mutations
5698
- GraphQL beta fields are unstable and shouldn't be used → **Partially true**. Beta fields can change without notice and are intended for experimentation, but they provide access to newer features
5799
- ## Related
58100
- [[Atlassian/Confluence/API/GraphQL]]

0 commit comments

Comments
 (0)