graphql
Version:
A Query Language and Runtime which can target any service.
67 lines (55 loc) • 1.97 kB
JavaScript
/* @flow */
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
;
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var _Object$defineProperty = require('babel-runtime/core-js/object/define-property')['default'];
_Object$defineProperty(exports, '__esModule', {
value: true
});
var _definition = require('./definition');
var _scalars = require('./scalars');
/**
* Directives are used by the GraphQL runtime as a way of modifying execution
* behavior. Type system creators will usually not create these directly.
*/
var GraphQLDirective = function GraphQLDirective(config) {
_classCallCheck(this, GraphQLDirective);
this.name = config.name;
this.description = config.description;
this.type = config.type;
this.onOperation = config.onOperation;
this.onFragment = config.onFragment;
this.onField = config.onField;
};
exports.GraphQLDirective = GraphQLDirective;
/**
* Used to conditionally include fields
*/
var GraphQLIfDirective = new GraphQLDirective({
name: 'if',
description: 'Directs the executor to omit this field if the argument ' + 'provided is false.',
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
onOperation: false,
onFragment: false,
onField: true
});
exports.GraphQLIfDirective = GraphQLIfDirective;
/**
* Used to conditionally exclude fields
*/
var GraphQLUnlessDirective = new GraphQLDirective({
name: 'unless',
description: 'Directs the executor to omit this field if the argument ' + 'provided is true.',
type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
onOperation: false,
onFragment: false,
onField: true
});
exports.GraphQLUnlessDirective = GraphQLUnlessDirective;