1 | import { isObjectType } from 'graphql';
|
2 | export 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 | }
|