UNPKG

graphql-compose-relay

Version:

Plugin for `graphql-compose` which wraps graphql types with Relay specific logic.

36 lines (30 loc) 928 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNodeInterface = getNodeInterface; exports.NodeInterface = void 0; var _graphqlCompose = require("graphql-compose"); const NodeTC = _graphqlCompose.InterfaceTypeComposer.createTemp({ name: 'Node', description: 'An object, that can be fetched by the globally unique ID among all types.', fields: { id: { type: 'ID!', description: 'The globally unique ID among all types.' } }, resolveType: payload => { // `payload.__nodeType` was added to payload via nodeFieldConfig.resolve return payload.__nodeType ? payload.__nodeType : null; } }); const NodeInterface = NodeTC.getType(); exports.NodeInterface = NodeInterface; function getNodeInterface(sc) { if (sc.hasInstance('Node', _graphqlCompose.InterfaceTypeComposer)) { return sc.get('Node'); } sc.set('Node', NodeTC); return NodeTC; }