UNPKG

t-graphql

Version:

typed GraphQL - end-to-end type-safe GraphQL for TypeScript. Think tRPC, but GraphQL

36 lines 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SchemaType = void 0; exports.schemaType = schemaType; var ObjectType_1 = require("./outputs/ObjectType"); var SchemaType = /** @class */ (function () { function SchemaType(queryType, mutationType, subscriptionType) { this.Query = queryType; this.Mutation = mutationType; this.Subscription = subscriptionType; } SchemaType.prototype.query = function (type) { if (this.Query.typename !== 'Query') { throw new Error('Only types named "Query" can be used as the root Query entrypoint'); } return new SchemaType(type, this.Mutation, this.Subscription); }; SchemaType.prototype.mutation = function (type) { if (type.typename !== 'Mutation') { throw new Error('Only types named "Mutation" can be used as the root Mutation entrypoint'); } return new SchemaType(this.Query, type, this.Subscription); }; SchemaType.prototype.subscription = function (type) { if (type.typename !== 'Subscription') { throw new Error('Only types named "Subscription" can be used as the root Subscription entrypoint'); } return new SchemaType(this.Query, this.Mutation, type); }; return SchemaType; }()); exports.SchemaType = SchemaType; function schemaType() { return new SchemaType((0, ObjectType_1.objectType)('Query'), (0, ObjectType_1.objectType)('Mutation'), (0, ObjectType_1.objectType)('Subscription')); } //# sourceMappingURL=SchemaType.js.map