Skip to content

Commit

Permalink
Patch @graphiql/react to list object types
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus committed Jan 20, 2023
1 parent 8933701 commit c0ec824
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 50 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@edgeandnode/graphiql-playground",
"version": "1.1.2",
"version": "1.2.0",
"type": "commonjs",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
Expand Down Expand Up @@ -37,13 +37,13 @@
},
"dependencies": {
"@graphiql/plugin-explorer": "0.1.12",
"@graphiql/react": "0.15.0",
"@graphiql/toolkit": "0.8.0"
},
"devDependencies": {
"@edgeandnode/components": "^24.4.2",
"@edgeandnode/eslint-config": "^1.1.0",
"@emotion/react": ">=11",
"@graphiql/react": "0.15.0",
"@jest/types": "^29.3.1",
"@types/codemirror": "^5.60.6",
"@types/jest": "^29.2.5",
Expand Down Expand Up @@ -82,6 +82,9 @@
"react": "18",
"react-dom": "18"
}
},
"patchedDependencies": {
"@graphiql/react@0.15.0": "patches/@graphiql__react@0.15.0.patch"
}
}
}
97 changes: 97 additions & 0 deletions patches/@graphiql__react@0.15.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
diff --git a/dist/index.es.js b/dist/index.es.js
index 16265a7d42b108f3d1581da746bd876c8251bb59..3963e015534beceff58291df7e40b7e8247c5ecd 100644
--- a/dist/index.es.js
+++ b/dist/index.es.js
@@ -135,13 +135,11 @@ globalThis && globalThis.__asyncValues || function(o2) {
});
};
}
function settle(resolve, reject, d2, v2) {
Promise.resolve(v2).then(function(v3) {
resolve({ value: v3, done: d2 });
}, reject);
}
};
globalThis && globalThis.__asyncGenerator || function(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
@@ -158,7 +156,6 @@ globalThis && globalThis.__asyncGenerator || function(thisArg, _arguments, gener
});
};
}
function resume(n2, v2) {
try {
step(g2[n2](v2));
@@ -166,24 +163,19 @@ globalThis && globalThis.__asyncGenerator || function(thisArg, _arguments, gener
settle(q2[0][3], e2);
}
}
function step(r2) {
r2.value instanceof __await ? Promise.resolve(r2.value.v).then(fulfill, reject) : settle(q2[0][2], r2);
}
function fulfill(value3) {
resume("next", value3);
}
function reject(value3) {
resume("throw", value3);
}
function settle(f2, v2) {
if (f2(v2), q2.shift(), q2.length)
resume(q2[0][0], q2[0][1]);
}
};
function stringify(obj) {
return JSON.stringify(obj, null, 2);
@@ -8669,7 +8661,6 @@ function useDropdownItem(_ref4) {
function listener() {
mouseEventStarted.current = false;
}
}, []);
return {
data: {
@@ -19643,6 +19634,9 @@ function SchemaDocumentation(props2) {
const queryType = props2.schema.getQueryType();
const mutationType = (_b = (_a = props2.schema).getMutationType) == null ? void 0 : _b.call(_a);
const subscriptionType = (_d = (_c = props2.schema).getSubscriptionType) == null ? void 0 : _d.call(_c);
+
+ const typeMap = props2.schema.getTypeMap && props2.schema.getTypeMap();
+
return /* @__PURE__ */ jsxs(Fragment, {
children: [/* @__PURE__ */ jsx(MarkdownContent, {
type: "description",
@@ -19671,6 +19665,29 @@ function SchemaDocumentation(props2) {
type: subscriptionType
})]
})]
+ }), !typeMap ? null : jsxs(ExplorerSection, {
+ title: "Possible Types",
+ children: [
+ Object.values(typeMap).map(typeValue => {
+ const renderedKinds = [
+ "Interface",
+ "Object",
+ ].map(s => `GraphQL${s}Type`)
+
+ const ctorName = typeValue.constructor.name
+ const typeName = typeValue.name;
+
+ const ignoredTypes = ['Query', 'Subscription'];
+
+ if (renderedKinds.includes(ctorName) && !ignoredTypes.includes(typeName) && typeName[0] !== '_') {
+ return jsxs("div", {
+ children: [jsx(TypeLink, { type: typeValue })],
+ })
+ }
+
+ return null;
+ })
+ ]
})]
});
}
@@ -19811,7 +19828,6 @@ function fillInChunks(_ref4) {
});
}
}
}
__name(fillInChunks, "fillInChunks");
function defaultSanitize(string) {
Loading

0 comments on commit c0ec824

Please sign in to comment.