UNPKG

552 BJavaScriptView Raw
1import { isObjectType } from 'graphql';
2export function getImplementingTypes(interfaceName, schema) {
3 const allTypesMap = schema.getTypeMap();
4 const result = [];
5 for (const graphqlTypeName in allTypesMap) {
6 const graphqlType = allTypesMap[graphqlTypeName];
7 if (isObjectType(graphqlType)) {
8 const allInterfaces = graphqlType.getInterfaces();
9 if (allInterfaces.find(int => int.name === interfaceName)) {
10 result.push(graphqlType.name);
11 }
12 }
13 }
14 return result;
15}