Closed alastair closed 3 years ago
It looks like the interface a schema in graphql-tools changed since we upgraded it. This patch appears to work:
diff --git a/src/helpers/SchemaHelper.js b/src/helpers/SchemaHelper.js
index 2cfb675..8ae1638 100644
--- a/src/helpers/SchemaHelper.js
+++ b/src/helpers/SchemaHelper.js
@@ -31,11 +31,11 @@ class SchemaHelper {
*/
findInterfaceImplementingTypes (interfaceName) {
const implementations = this.findInterface(interfaceName)
- if (!Array.isArray(implementations) || !implementations.length) {
+ if (!implementations.objects || !Array.isArray(implementations.objects) || !implementations.objects.length) {
return null
}
- return implementations.map(implementation => { return implementation.toString() })
+ return implementations.objects.map(implementation => { return implementation.toString() })
}
/**
@@ -43,7 +43,7 @@ class SchemaHelper {
* @returns {*|Array<GraphQLObjectType>}
*/
findInterface (interfaceName) {
- return this.schema.getImplementations(interfaceName)
+ return this.schema.getImplementations({name:interfaceName})
}
/**
when using the document api, only fields that are scalars or links to concrete types are returned. For example, a query
which returns
however, the json-ld response only includes:
It includes things like
source
which is just a String, and it also includesworkExampleMediaObject
which is our special field with the same relation name asworkExample
but with a type ofMediaObject
rather than ThingInterface.The fields for workExample and composer don't appear in the returned json.
The issue seems to be that
SchemaHelper.findInterfaceImplementingTypes
https://github.com/trompamusic/ce-api/blob/c95fc49dc836569a3d6c8f3d4f55d7ee59150a01/src/helpers/QueryHelper.js#L96-L97 is returning null when trying to findschema.getImplementations
of an interface name.