1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.GQLInterface = undefined;
|
7 |
|
8 | var _GQLBase = require('./GQLBase');
|
9 |
|
10 | var _graphql = require('graphql');
|
11 |
|
12 | /**
|
13 | * Used by Lattice to implement interface types in the schema when necessary
|
14 | *
|
15 | * @class GQLInterface
|
16 | */
|
17 | /**
|
18 | @namespace GQLInterface
|
19 |
|
20 | */
|
21 |
|
22 | let GQLInterface = exports.GQLInterface = class GQLInterface extends _GQLBase.GQLBase {
|
23 |
|
24 | /**
|
25 | * This needs to be able to, depending on your implementors, identify
|
26 | * which on the data actually is given the model to work with.
|
27 | *
|
28 | * @memberof GQLInterface
|
29 | * @method ⌾⠀resolveType
|
30 | * @static
|
31 | *
|
32 | * @param {mixed} model the data you can use to instantiate the type of
|
33 | * object in question.
|
34 | * @return {string} a string matching the name of a defined GraphQL type
|
35 | * found elsewhere in your schema
|
36 | */
|
37 | static resolveType(model) {
|
38 | throw new Error(`
|
39 | You must override "resolveType(model)" in your GQLInterface instance
|
40 | and determine the implementor type by the contents of the supplied
|
41 | model. Returning "null" when nothing matches.
|
42 | `);
|
43 | }
|
44 |
|
45 | /**
|
46 | * Denotes that this GQLBase descendent is describing a graphql
|
47 | * interface type.
|
48 | *
|
49 | * @memberof GQLInterface
|
50 | * @method ⬇︎⠀GQL_TYPE
|
51 | * @static
|
52 | * @const
|
53 | *
|
54 | * @return {Function} a type, such as `GraphQLObjectType` or
|
55 | * `GraphQLInterfaceType`
|
56 | */
|
57 | static get GQL_TYPE() {
|
58 | return _graphql.GraphQLInterfaceType;
|
59 | }
|
60 | };
|
61 | //# sourceMappingURL=GQLInterface.js.map |
\ | No newline at end of file |