🛠️DevTools

GraphQL Response Viewer

Explore GraphQL responses with their typical nested structure including edges, nodes, and pageInfo.

Code Examples

Here's how to achieve this in different programming languages:

1// Parse and traverse JSON
2const jsonData = {
3 "data": {
4 "user": {
5 "id": "usr_123",
6 "username": "johndoe",
7 "email": "john@example.com",
8 "posts": {
9 "edges": [
10 {
11 "node": {
12 "id": "post_1",
13 "title": "Getting Started with GraphQL",
14 "publishedAt": "2024-01-10T09:00:00Z",
15 "likes": 42
16 }
17 },
18 {
19 "node": {
20 "id": "post_2",
21 "title": "Advanced Query Patterns",
22 "publishedAt": "2024-01-15T14:30:00Z",
23 "likes": 28
24 }
25 }
26 ],
27 "pageInfo": {
28 "hasNextPage": true,
29 "endCursor": "cursor_abc123"
30 }
31 }
32 }
33 },
34 "extensions": {
35 "complexity": 15,
36 "requestId": "req_xyz789"
37 }
38};
39
40// Access nested values
41function getValue(obj, path) {
42 return path.split('.').reduce((acc, key) => acc?.[key], obj);
43}
44
45// Get all paths in JSON
46function getAllPaths(obj, prefix = '') {
47 const paths = [];
48 for (const [key, value] of Object.entries(obj)) {
49 const path = prefix ? `${prefix}.${key}` : key;
50 paths.push(path);
51 if (typeof value === 'object' && value !== null) {
52 paths.push(...getAllPaths(value, path));
53 }
54 }
55 return paths;
56}
57
58console.log(getAllPaths(jsonData));

More JSON Examples

Related JSON Tools

📚 Learn More