UNPKG

@txstate-mws/graphql-server

Version:

A simple graphql server designed to work with typegraphql.

23 lines (22 loc) 794 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.shasum = shasum; exports.NoIntrospection = NoIntrospection; const crypto_1 = __importDefault(require("crypto")); const graphql_1 = require("graphql"); function shasum(str) { return crypto_1.default.createHash('sha256').update(str).digest('hex'); } const disallowed = { __schema: true, __type: true }; function NoIntrospection(context) { return { Field(node) { if (disallowed[node.name.value]) { context.reportError(new graphql_1.GraphQLError('GraphQL introspection is not allowed.', [node])); } } }; }