all files / semantic-graphql/src/graphql/ getGraphqlInterfaceType.js

100% Statements 9/9
100% Branches 0/0
100% Functions 1/1
100% Lines 9/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                  
const { GraphQLInterfaceType } = require('graphql');
const memorize = require('../graph/memorize');
const ensureResourceExistance = require('../graph/ensureResourceExistance');
const getGraphqlName = require('./getGraphqlName');
const getGraphqlTypeResolver = require('./getGraphqlTypeResolver');
 
function getGraphqlInterfaceType(g, iri) {
 
  return new GraphQLInterfaceType({
    name: `${getGraphqlName(g, iri)}Interface`,
    description: `Interface for ${iri}`,
    fields: () => require('./getGraphqlFieldConfigMap')(g, iri), // dynamic require to prevent require cycles
    resolveType: getGraphqlTypeResolver(g, iri),
  });
}
 
module.exports = ensureResourceExistance(memorize(getGraphqlInterfaceType, 'graphqlInterfaceType'));