Fix Unknow type merge bug on overloaded types (#6494)
* Fix Unknow type bug on overloaded types * check args too
This commit is contained in:
@@ -211,7 +211,33 @@ class ParseGraphQLSchema {
|
||||
const autoGraphQLSchemaType = this.graphQLAutoSchema.getType(
|
||||
customGraphQLSchemaType.name
|
||||
);
|
||||
if (autoGraphQLSchemaType) {
|
||||
if (
|
||||
autoGraphQLSchemaType &&
|
||||
typeof customGraphQLSchemaType.getFields === 'function'
|
||||
) {
|
||||
const findAndAddLastType = type => {
|
||||
if (type.name) {
|
||||
if (!this.graphQLAutoSchema.getType(type)) {
|
||||
// To avoid schema stitching (Unknow type) bug on variables
|
||||
// transfer the final type to the Auto Schema
|
||||
this.graphQLAutoSchema._typeMap[type.name] = type;
|
||||
}
|
||||
} else {
|
||||
if (type.ofType) {
|
||||
findAndAddLastType(type.ofType);
|
||||
}
|
||||
}
|
||||
};
|
||||
Object.values(customGraphQLSchemaType.getFields()).forEach(
|
||||
field => {
|
||||
findAndAddLastType(field.type);
|
||||
if (field.args) {
|
||||
field.args.forEach(arg => {
|
||||
findAndAddLastType(arg.type);
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
autoGraphQLSchemaType._fields = {
|
||||
...autoGraphQLSchemaType._fields,
|
||||
...customGraphQLSchemaType._fields,
|
||||
|
||||
Reference in New Issue
Block a user