Skip to content
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

🐛 More precise mapping resolving #32

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions patches/@graphql-tools+executor+1.2.1.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/node_modules/@graphql-tools/executor/cjs/execution/execute.js b/node_modules/@graphql-tools/executor/cjs/execution/execute.js
old mode 100644
new mode 100755
index 791e3df..ae399d9
index 791e3df..0210559
--- a/node_modules/@graphql-tools/executor/cjs/execution/execute.js
+++ b/node_modules/@graphql-tools/executor/cjs/execution/execute.js
@@ -628,8 +628,13 @@ function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, r
Expand All @@ -19,7 +19,7 @@ index 791e3df..ae399d9
}
// releases before 16.0.0 supported returning `GraphQLObjectType` from `resolveType`
// TODO: remove in 17.0.0 release
@@ -640,6 +645,17 @@ function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNo
@@ -640,6 +645,25 @@ function ensureValidRuntimeType(runtimeTypeName, exeContext, returnType, fieldNo
throw (0, utils_1.createGraphQLError)(`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with ` +
`value ${(0, utils_1.inspect)(result)}, received "${(0, utils_1.inspect)(runtimeTypeName)}".`);
}
Expand All @@ -29,7 +29,15 @@ index 791e3df..ae399d9
+ .find(a => a.name.value === "mapping").value.value)
+ Object.keys(mappedTypes).forEach((type) => {
+ // For each key in the mapping object, check if the runtimeTypeName includes the key
+ if (runtimeTypeName.includes(type)) {
+ const splits = runtimeTypeName.split('_')
+ // Remove the version
+ splits.pop()
+ let joinedSplits = splits.join('_')
+ // If the runtimeTypeName is not versioned
+ if (joinedSplits === "") {
+ joinedSplits = runtimeTypeName
+ }
+ if (joinedSplits === type) {
+ // Replace the key with its corresponding mapped type in the runtimeTypeName
+ runtimeTypeName = runtimeTypeName.replace(type, mappedTypes[type])
+ }
Expand Down
Loading