Skip to content

Commit 116d5ef

Browse files
authored
Merge pull request #946 from MITLibraries/backfill-adr-for-graphql
Add ADR to use GraphQL instead of REST
2 parents 041d0a1 + 29fd2fe commit 116d5ef

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

docs/architecture-decisions/0004-use-openapi-specification.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Date: 2018-10-16
44

55
## Status
66

7-
Accepted
7+
Superceded by [6. Use GraphQL for API](0006-use-graphql-for-api.md)
88

99
## Context
1010

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# 6. Use GraphQL for API
2+
3+
Date: 2023-08-07
4+
5+
## Status
6+
7+
Accepted
8+
9+
Supercedes [4. Use OpenAPI Specification](0004-use-openapi-specification.md)
10+
11+
## Context
12+
13+
The initial TIMDEX implementation chose a REST API. During development of new expanded features, we revisted this decision and looked at our options and needs.
14+
15+
### Options Considered
16+
17+
#### GraphQL
18+
19+
**Description:** GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.
20+
21+
**Pros:**
22+
23+
- GraphiQL interactive editor allows users to explore the API without writing any code
24+
- Users can request the exact data they want as part of the query
25+
- Schema allows users and applications to import and understand data types
26+
27+
**Cons:**
28+
29+
- Requires developers to learn GraphQL syntax
30+
- More difficult to scale with simple caching
31+
32+
#### OpenAPI spec REST API
33+
34+
**Description:** The OpenAPI Specification is a specification for machine-readable interface files for describing, producing, consuming, and visualizing RESTful web services.
35+
36+
**Pros:**
37+
38+
- REST APIs are comfortable for many developers as they have used them before
39+
- uses OpenAPI spec and transitioning to V2 in OpenAPI would be familiar
40+
41+
**Neutral:**
42+
43+
- v2 requires significant changes to v1 and is essentially a rewrite so any apps using v1 will need to make changes regardless of if we keep this similar spec
44+
- Auto generation of documentation is useful, but does not meet all of our documentation plans for v2
45+
46+
**Cons:**
47+
48+
- Requires many decisions to be made as to how to request data when designing the spec
49+
- The only way to know how to use the API will be to rely on our spec and our documentation
50+
51+
#### JSON API
52+
53+
**Description:** JSON:API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests. JSON:API is designed to minimize both the number of requests and the amount of data transmitted between clients and servers. This efficiency is achieved without compromising readability, flexibility, or discoverability.
54+
55+
**Pros:**
56+
57+
- Adds standardization to REST APIs
58+
59+
**Cons:**
60+
61+
- Unclear how well adopted it is
62+
63+
## Decision
64+
65+
We will replace our REST API with a GraphQL API.
66+
67+
## Consequences
68+
69+
Users can request the specific fields they want, and we can more easily handle field deprecations.
70+
71+
We will also have a GraphQL playground for testing queries without having to write code.

0 commit comments

Comments
 (0)