Search is not available for this dataset
query
stringlengths
7
355k
document
stringlengths
9
341k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Creates a new visitor instance which maintains a provided TypeInfo instance along with visiting visitor.
function visitWithTypeInfo(typeInfo, visitor) { return { enter: function enter(node) { typeInfo.enter(node); var fn = getVisitFn(visitor, node.kind, /* isLeaving */false); if (fn) { var result = fn.apply(visitor, arguments); if (result !== undefined) { typeInfo.leave(node); if (isNode(result)) { typeInfo.enter(result); } } return result; } }, leave: function leave(node) { var fn = getVisitFn(visitor, node.kind, /* isLeaving */true); var result = void 0; if (fn) { result = fn.apply(visitor, arguments); } typeInfo.leave(node); return result; } }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function visitWithTypeInfo(typeInfo, visitor) {\n return {\n enter: function enter(node) {\n typeInfo.enter(node);\n var fn = Object(_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_3__[\"getVisitFn\"])(visitor, node.kind,\n /* isLeaving */\n false);\n\n if (fn) {\n var result = f...
[ "0.72599155", "0.72573745", "0.7228485", "0.7228246", "0.72128725", "0.7197253", "0.7197253", "0.7197253", "0.7197253", "0.7197253", "0.7197253", "0.71903217", "0.71903217", "0.71898746", "0.7103658", "0.7103658", "0.57449543", "0.57449543", "0.57449543", "0.57006234", "0.570...
0.7203711
16
Given a visitor instance, if it is leaving or not, and a node kind, return the function the visitor runtime should call.
function getVisitFn(visitor, kind, isLeaving) { var kindVisitor = visitor[kind]; if (kindVisitor) { if (!isLeaving && typeof kindVisitor === 'function') { // { Kind() {} } return kindVisitor; } var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter; if (typeof kindSpecificVisitor === 'function') { // { Kind: { enter() {}, leave() {} } } return kindSpecificVisitor; } } else { var specificVisitor = isLeaving ? visitor.leave : visitor.enter; if (specificVisitor) { if (typeof specificVisitor === 'function') { // { enter() {}, leave() {} } return specificVisitor; } var specificKindVisitor = specificVisitor[kind]; if (typeof specificKindVisitor === 'function') { // { enter: { Kind() {} }, leave: { Kind() {} } } return specificKindVisitor; } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getVisitFn(visitor, kind, isLeaving) {\n var kindVisitor = visitor[kind];\n if (kindVisitor) {\n if (!isLeaving && typeof kindVisitor === 'function') {\n // { Kind() {} }\n return kindVisitor;\n }\n var kindSpecificVisitor = isLeaving ? kindVisitor.leave : ...
[ "0.735789", "0.7335283", "0.73079747", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7282289", "0.7262107", "...
0.72866946
15
Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function find(list, predicate) { for (var i = 0; i < list.length; i++) { if (predicate(list[i])) { return list[i]; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "componentDidMount() {\n // if this is the first time the home screen is loading\n // we must initialize Facebook\n if (!window.FB) {\n window.fbAsyncInit = function() {\n window.FB.init({\n appId : '280945375708713',\n cookie : true, // enable cookies to allow the s...
[ "0.5976053", "0.57203424", "0.57181513", "0.5614843", "0.56018084", "0.55464816", "0.54893225", "0.5453807", "0.5409828", "0.53852314", "0.5378477", "0.53759915", "0.537015", "0.53436714", "0.53220254", "0.53067243", "0.5306326", "0.5264811", "0.5253494", "0.5253494", "0.5162...
0.0
-1
Given a Schema and an AST node describing a type, return a GraphQLType definition which applies to that type. For example, if provided the parsed AST node for `[User]`, a GraphQLList instance will be returned, containing the type called "User" found in the schema. If a type called "User" is not found in the schema, then undefined will be returned. / eslintdisable noredeclare
function typeFromASTImpl(schema, typeNode) { /* eslint-enable no-redeclare */ var innerType = void 0; if (typeNode.kind === Kind.LIST_TYPE) { innerType = typeFromAST(schema, typeNode.type); return innerType && new _definition.GraphQLList(innerType); } if (typeNode.kind === Kind.NON_NULL_TYPE) { innerType = typeFromAST(schema, typeNode.type); return innerType && new _definition.GraphQLNonNull(innerType); } !(typeNode.kind === Kind.NAMED_TYPE) ? (0, _invariant2.default)(0, 'Must be a named type.') : void 0; return schema.getType(typeNode.name.value); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function typeFromASTImpl(schema, typeNode) {\n /* eslint-enable no-redeclare */\n var innerType = void 0;\n if (typeNode.kind === _kinds.LIST_TYPE) {\n innerType = typeFromAST(schema, typeNode.type);\n return innerType && new _definition.GraphQLList(innerType);\n }\n if (typeNode.kind === _kinds.NON_NUL...
[ "0.77333605", "0.77222663", "0.75492275", "0.7540867", "0.752867", "0.651093", "0.63268805", "0.6272108", "0.6262849", "0.6195216", "0.6074667", "0.6074667", "0.60441387", "0.60441387", "0.600616", "0.5792621", "0.5789407", "0.5765346", "0.5761791", "0.5749845", "0.5732424", ...
0.77242106
2
get current script URL
function getJsUrl() { var id = +new Date() + Math.random(); try { // write empty script to the document. It will get placed directly after the current script document.write("<script id=\"dummy" + id + "\"></script>"); // find appended script and return src of the previous script which is the current script return document.getElementById('dummy' + id).previousSibling.src; } catch (e) { return ''; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getCurrentURL() {\n return window.location.href;\n}", "function getCurrentScriptSrc() {\n if (document.currentScript) return document.currentScript.src;\n\n // this is unreliable if the script is loaded asynchronously\n var scripts = document.getElementsByTagName('script');\n return scripts[scripts...
[ "0.742416", "0.72736424", "0.7257845", "0.7225784", "0.72139895", "0.7150679", "0.7142431", "0.71399367", "0.7131592", "0.7131592", "0.7131592", "0.7131592", "0.7131592", "0.7131592", "0.7131592", "0.71105313", "0.6965575", "0.68907803", "0.68834144", "0.68652886", "0.6856497...
0.64388263
38
Copyright Joyent, Inc. and other Node contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. resolves . and .. elements in a path array with directory names there must be no slashes, empty elements, or device names (c:\) in the array (so also no leading and trailing slashes it does not distinguish relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) { // if the path tries to go above the root, `up` ends up > 0 var up = 0; for (var i = parts.length - 1; i >= 0; i--) { var last = parts[i]; if (last === '.') { parts.splice(i, 1); } else if (last === '..') { parts.splice(i, 1); up++; } else if (up) { parts.splice(i, 1); up--; } } // if the path is allowed to go above the root, restore leading ..s if (allowAboveRoot) { for (; up--; up) { parts.unshift('..'); } } return parts; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function rationalizePaths(array){\n for(var i = 0, len = array.length; i < len; i++){\n //I know, this is very unneeded, but I like having it because of it's over bearing round-a-bout-ness\n array[i] = require.resolve(array[i]).split('\\\\').filter(function(o,i,a){ return (a.length-1) !== i; }).jo...
[ "0.6256403", "0.60911584", "0.59586495", "0.59263116", "0.5910633", "0.5872318", "0.58496606", "0.5819388", "0.5760077", "0.5742037", "0.5710566", "0.5640613", "0.5557485", "0.5512614", "0.54774433", "0.5438204", "0.5434192", "0.5434087", "0.542859", "0.54018843", "0.5399512"...
0.0
-1
Converts a name lex token into a name parse node.
function parseName(lexer) { var token = expect(lexer, _lexer.TokenKind.NAME); return { kind: _kinds.NAME, value: token.value, loc: loc(lexer, token) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseName() {\n const token = this.expectToken(TokenKind.NAME);\n return this.node(token, {\n kind: Kind.NAME,\n value: token.value,\n });\n }", "function parseName(lexer) {\n\t var token = expect(lexer, _lexer.TokenKind.NAME);\n\t return {\n\t kind: _kinds.NAME,\n\t value: token.valu...
[ "0.78040475", "0.7478694", "0.7478694", "0.74510324", "0.74510324", "0.74510324", "0.74510324", "0.74510324", "0.7436509", "0.7434923", "0.7361506", "0.7329967", "0.7329967", "0.7211023", "0.71690416", "0.70296836", "0.5992738", "0.5884825", "0.5857028", "0.57604516", "0.5743...
0.74547267
8
Implements the parsing rules in the Document section. Document : Definition+
function parseDocument(lexer) { var start = lexer.token; expect(lexer, _lexer.TokenKind.SOF); var definitions = []; do { definitions.push(parseDefinition(lexer)); } while (!skip(lexer, _lexer.TokenKind.EOF)); return { kind: _kinds.DOCUMENT, definitions: definitions, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseDocument() {\n return this.node(this._lexer.token, {\n kind: Kind.DOCUMENT,\n definitions: this.many(\n TokenKind.SOF,\n this.parseDefinition,\n TokenKind.EOF,\n ),\n });\n }", "constructor(schema, rules) {\n this.schema = schema;\n this.rules = rules;\n t...
[ "0.62960064", "0.5888885", "0.5772888", "0.57425183", "0.5736046", "0.56977725", "0.56977725", "0.568532", "0.5638602", "0.5627307", "0.56254566", "0.5625318", "0.5585372", "0.55778307", "0.55778307", "0.55778307", "0.55778307", "0.5551567", "0.5528839", "0.55035377", "0.5498...
0.5545718
22
Definition : OperationDefinition FragmentDefinition TypeSystemDefinition
function parseDefinition(lexer) { if (peek(lexer, _lexer.TokenKind.BRACE_L)) { return parseOperationDefinition(lexer); } if (peek(lexer, _lexer.TokenKind.NAME)) { switch (lexer.token.value) { // Note: subscription is an experimental non-spec addition. case 'query': case 'mutation': case 'subscription': return parseOperationDefinition(lexer); case 'fragment': return parseFragmentDefinition(lexer); // Note: the Type System IDL is an experimental non-spec addition. case 'schema': case 'scalar': case 'type': case 'interface': case 'union': case 'enum': case 'input': case 'extend': case 'directive': return parseTypeSystemDefinition(lexer); } } throw unexpected(lexer); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseOperationTypeDefinition() {\n const start = this._lexer.token;\n const operation = this.parseOperationType();\n this.expectToken(TokenKind.COLON);\n const type = this.parseNamedType();\n return this.node(start, {\n kind: Kind.OPERATION_TYPE_DEFINITION,\n operation,\n type,\n }...
[ "0.68411225", "0.635306", "0.63322926", "0.6169092", "0.6144218", "0.6144218", "0.6144218", "0.6144218", "0.6144218", "0.6109615", "0.6041015", "0.6037591", "0.60056716", "0.60050434", "0.59893894", "0.59657955", "0.5926603", "0.5926603", "0.5919677", "0.5919677", "0.5919677"...
0.6023362
17
Implements the parsing rules in the Operations section. OperationDefinition : SelectionSet OperationType Name? VariableDefinitions? Directives? SelectionSet
function parseOperationDefinition(lexer) { var start = lexer.token; if (peek(lexer, _lexer.TokenKind.BRACE_L)) { return { kind: _kinds.OPERATION_DEFINITION, operation: 'query', name: null, variableDefinitions: null, directives: [], selectionSet: parseSelectionSet(lexer), loc: loc(lexer, start) }; } var operation = parseOperationType(lexer); var name = void 0; if (peek(lexer, _lexer.TokenKind.NAME)) { name = parseName(lexer); } return { kind: _kinds.OPERATION_DEFINITION, operation: operation, name: name, variableDefinitions: parseVariableDefinitions(lexer), directives: parseDirectives(lexer), selectionSet: parseSelectionSet(lexer), loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseOperationDefinition() {\n const start = this._lexer.token;\n\n if (this.peek(TokenKind.BRACE_L)) {\n return this.node(start, {\n kind: Kind.OPERATION_DEFINITION,\n operation: OperationTypeNode.QUERY,\n name: undefined,\n variableDefinitions: [],\n directives: [],\...
[ "0.74767596", "0.696236", "0.6958122", "0.6947385", "0.6947385", "0.6947385", "0.6947385", "0.69105035", "0.69035834", "0.68435615", "0.6835411", "0.6835411", "0.6823374", "0.67332166", "0.65722954", "0.65679526", "0.652372", "0.6358887", "0.6266334", "0.6266334", "0.6266334"...
0.6859196
13
OperationType : one of query mutation subscription
function parseOperationType(lexer) { var operationToken = expect(lexer, _lexer.TokenKind.NAME); switch (operationToken.value) { case 'query': return 'query'; case 'mutation': return 'mutation'; // Note: subscription is an experimental non-spec addition. case 'subscription': return 'subscription'; } throw unexpected(lexer, operationToken); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseOperationType() {\n const operationToken = this.expectToken(TokenKind.NAME);\n\n switch (operationToken.value) {\n case 'query':\n return OperationTypeNode.QUERY;\n\n case 'mutation':\n return OperationTypeNode.MUTATION;\n\n case 'subscription':\n return OperationType...
[ "0.6767044", "0.66750133", "0.6667136", "0.66366386", "0.66044563", "0.66044563", "0.66044563", "0.66044563", "0.6600803", "0.65488625", "0.64355683", "0.64009553", "0.63313407", "0.63313407", "0.625439", "0.6230422", "0.6160315", "0.6160315", "0.6087882", "0.60845375", "0.60...
0.6696435
5
VariableDefinitions : ( VariableDefinition+ )
function parseVariableDefinitions(lexer) { return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseVariableDefinition, _lexer.TokenKind.PAREN_R) : []; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseVariableDefinitions() {\n return this.optionalMany(\n TokenKind.PAREN_L,\n this.parseVariableDefinition,\n TokenKind.PAREN_R,\n );\n }", "function parseVariableDefinitions(lexer$$1) {\n return peek(lexer$$1, lexer.TokenKind.PAREN_L) ? many(lexer$$1, lexer.TokenKind.PAREN_L, parseVaria...
[ "0.7294105", "0.7109119", "0.7006673", "0.7006673", "0.6995079", "0.68373275", "0.6801801", "0.6702027", "0.66963965", "0.669627", "0.669627", "0.66889995", "0.6667154", "0.66397494", "0.66358685", "0.6611495", "0.6594916", "0.6592061", "0.6567994", "0.6567994", "0.6567994", ...
0.69709283
13
VariableDefinition : Variable : Type DefaultValue?
function parseVariableDefinition(lexer) { var start = lexer.token; return { kind: _kinds.VARIABLE_DEFINITION, variable: parseVariable(lexer), type: (expect(lexer, _lexer.TokenKind.COLON), parseTypeReference(lexer)), defaultValue: skip(lexer, _lexer.TokenKind.EQUALS) ? parseValueLiteral(lexer, true) : null, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseVariableDefinition() {\n return this.node(this._lexer.token, {\n kind: Kind.VARIABLE_DEFINITION,\n variable: this.parseVariable(),\n type: (this.expectToken(TokenKind.COLON), this.parseTypeReference()),\n defaultValue: this.expectOptionalToken(TokenKind.EQUALS)\n ? this.parseCons...
[ "0.6858048", "0.6546352", "0.64285564", "0.6237643", "0.62253755", "0.6216707", "0.62068427", "0.6157156", "0.6157156", "0.6157156", "0.6157156", "0.61292505", "0.6115962", "0.60804886", "0.60211694", "0.60082185", "0.6001197", "0.5978874", "0.59529495", "0.592531", "0.591904...
0.6164193
11
Variable : $ Name
function parseVariable(lexer) { var start = lexer.token; expect(lexer, _lexer.TokenKind.DOLLAR); return { kind: _kinds.VARIABLE, name: parseName(lexer), loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createVariable() {\n var id = nextVariableId++;\n var name = '$V';\n\n do {\n name += variableTokens[id % variableTokensLength];\n id = ~~(id / variableTokensLength);\n } while (id !== 0);\n\n return name;\n }", "function makeVar(root, name) {\n name = name.toLowerCase().rep...
[ "0.6945701", "0.6884038", "0.6858726", "0.6830075", "0.6722742", "0.669976", "0.66969347", "0.6647729", "0.6564104", "0.65095234", "0.6448056", "0.6433639", "0.6406728", "0.6377274", "0.63718086", "0.63441086", "0.6315028", "0.6285289", "0.62734824", "0.62667507", "0.62561864...
0.0
-1
Selection : Field FragmentSpread InlineFragment
function parseSelection(lexer) { return peek(lexer, _lexer.TokenKind.SPREAD) ? parseFragment(lexer) : parseField(lexer); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseSelection() {\n return this.peek(TokenKind.SPREAD)\n ? this.parseFragment()\n : this.parseField();\n }", "function parseSelection(lexer) {\n return peek(lexer, TokenKind.SPREAD) ? parseFragment(lexer) : parseField(lexer);\n}", "function parseSelection(lexer) {\n\t return peek(lexer, _lexer...
[ "0.69309527", "0.6277677", "0.6232537", "0.6232537", "0.61205184", "0.6051091", "0.6038953", "0.6020248", "0.5971852", "0.5954627", "0.5865732", "0.58636636", "0.58636636", "0.57569814", "0.5751134", "0.5751134", "0.57143056", "0.5691664", "0.5689914", "0.5689914", "0.5689914...
0.622574
14
Field : Alias? Name Arguments? Directives? SelectionSet? Alias : Name :
function parseField(lexer) { var start = lexer.token; var nameOrAlias = parseName(lexer); var alias = void 0; var name = void 0; if (skip(lexer, _lexer.TokenKind.COLON)) { alias = nameOrAlias; name = parseName(lexer); } else { alias = null; name = nameOrAlias; } return { kind: _kinds.FIELD, alias: alias, name: name, arguments: parseArguments(lexer), directives: parseDirectives(lexer), selectionSet: peek(lexer, _lexer.TokenKind.BRACE_L) ? parseSelectionSet(lexer) : null, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function $Alias() {\n\t\treturn Field.apply(this, arguments);\n\t}", "field (field, alias = null, options = {}) {\n alias = alias ? this._sanitizeFieldAlias(alias) : alias;\n field = this._sanitizeField(field);\n\n // if field-alias combo already present then don't add\n let existingField = t...
[ "0.67461413", "0.5861788", "0.583103", "0.5825715", "0.57540786", "0.5662482", "0.5464285", "0.54340297", "0.5398831", "0.53741914", "0.53367126", "0.53101426", "0.5289533", "0.5271213", "0.5269528", "0.5256967", "0.5246766", "0.5243333", "0.5239582", "0.52185047", "0.5181147...
0.5024166
41
Arguments : ( Argument+ )
function parseArguments(lexer) { return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseArgument, _lexer.TokenKind.PAREN_R) : []; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function args() {\n\n}", "function SimpleArgs() {\r\n}", "function saludarArgumentos(referencia){\n console.log(arguments);\n}", "function functionWithArgs(a,b){\n console.log(a+b);\n }", "function args() {\n return Array.prototype.slice.call(arguments[0]);\n }", "function add() {\n\tvar _args...
[ "0.7352356", "0.7198588", "0.7013198", "0.69684076", "0.696082", "0.6909816", "0.687237", "0.6858448", "0.68460864", "0.68198824", "0.68062013", "0.6779013", "0.67783326", "0.6776742", "0.67684937", "0.6751083", "0.67449814", "0.6735543", "0.6734999", "0.6728472", "0.67099464...
0.0
-1
Argument : Name : Value
function parseArgument(lexer) { var start = lexer.token; return { kind: _kinds.ARGUMENT, name: parseName(lexer), value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, false)), loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "set name(value) {}", "set name(value) {}", "set name(value) {}", "set name(value) {}", "set name(value) {}", "set name(value) {}", "set name(value) {}", "function NamedArgument(nameArg, valueArg) {\n this.nameArg = nameArg;\n this.valueArg = valueArg;\n\n if (valueArg == null) {\n this.text = '...
[ "0.72060025", "0.72060025", "0.72060025", "0.72060025", "0.72060025", "0.72060025", "0.72060025", "0.6422374", "0.64010113", "0.62037766", "0.6194418", "0.6177072", "0.61311734", "0.612789", "0.6106977", "0.6090025", "0.607602", "0.6045148", "0.59991854", "0.5996516", "0.5980...
0.0
-1
Implements the parsing rules in the Fragments section. Corresponds to both FragmentSpread and InlineFragment in the spec. FragmentSpread : ... FragmentName Directives? InlineFragment : ... TypeCondition? Directives? SelectionSet
function parseFragment(lexer) { var start = lexer.token; expect(lexer, _lexer.TokenKind.SPREAD); if (peek(lexer, _lexer.TokenKind.NAME) && lexer.token.value !== 'on') { return { kind: _kinds.FRAGMENT_SPREAD, name: parseFragmentName(lexer), directives: parseDirectives(lexer), loc: loc(lexer, start) }; } var typeCondition = null; if (lexer.token.value === 'on') { lexer.advance(); typeCondition = parseNamedType(lexer); } return { kind: _kinds.INLINE_FRAGMENT, typeCondition: typeCondition, directives: parseDirectives(lexer), selectionSet: parseSelectionSet(lexer), loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseFragment() {\n const start = this._lexer.token;\n this.expectToken(TokenKind.SPREAD);\n const hasTypeCondition = this.expectOptionalKeyword('on');\n\n if (!hasTypeCondition && this.peek(TokenKind.NAME)) {\n return this.node(start, {\n kind: Kind.FRAGMENT_SPREAD,\n name: this.par...
[ "0.7206461", "0.71676755", "0.6914399", "0.6912697", "0.6912697", "0.6910929", "0.6888611", "0.6878452", "0.6877602", "0.68624246", "0.68624246", "0.68624246", "0.68624246", "0.68596417", "0.6797236", "0.67814314", "0.67814314", "0.67276645", "0.671112", "0.6699759", "0.66997...
0.6622049
30
FragmentDefinition : fragment FragmentName on TypeCondition Directives? SelectionSet TypeCondition : NamedType
function parseFragmentDefinition(lexer) { var start = lexer.token; expectKeyword(lexer, 'fragment'); return { kind: _kinds.FRAGMENT_DEFINITION, name: parseFragmentName(lexer), typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)), directives: parseDirectives(lexer), selectionSet: parseSelectionSet(lexer), loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseFragment() {\n const start = this._lexer.token;\n this.expectToken(TokenKind.SPREAD);\n const hasTypeCondition = this.expectOptionalKeyword('on');\n\n if (!hasTypeCondition && this.peek(TokenKind.NAME)) {\n return this.node(start, {\n kind: Kind.FRAGMENT_SPREAD,\n name: this.par...
[ "0.74768233", "0.7459269", "0.70694095", "0.6926619", "0.6903476", "0.68996274", "0.68996274", "0.68996274", "0.68996274", "0.6886915", "0.68579525", "0.6853531", "0.68519825", "0.68519825", "0.68485284", "0.6847869", "0.6736703", "0.64843434", "0.64811015", "0.6359786", "0.6...
0.70067626
7
FragmentName : Name but not `on`
function parseFragmentName(lexer) { if (lexer.token.value === 'on') { throw unexpected(lexer); } return parseName(lexer); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseFragmentName() {\n if (this._lexer.token.value === 'on') {\n throw this.unexpected();\n }\n\n return this.parseName();\n }", "function parseFragmentName(parser) {\n\t if (parser.token.value === 'on') {\n\t throw unexpected(parser);\n\t }\n\t return parseName(parser);\n\t}", "function ...
[ "0.7956079", "0.7754376", "0.7729181", "0.7729181", "0.7622439", "0.7586603", "0.7586603", "0.7586603", "0.7586603", "0.7586603", "0.7586603", "0.7443", "0.66180825", "0.65736175", "0.65621245", "0.6561956", "0.65459627", "0.65121806", "0.649947", "0.64661705", "0.64626426", ...
0.76194835
13
Implements the parsing rules in the Values section. Value[Const] : [~Const] Variable IntValue FloatValue StringValue BooleanValue NullValue EnumValue ListValue[?Const] ObjectValue[?Const] BooleanValue : one of `true` `false` NullValue : `null` EnumValue : Name but not `true`, `false` or `null`
function parseValueLiteral(lexer, isConst) { var token = lexer.token; switch (token.kind) { case _lexer.TokenKind.BRACKET_L: return parseList(lexer, isConst); case _lexer.TokenKind.BRACE_L: return parseObject(lexer, isConst); case _lexer.TokenKind.INT: lexer.advance(); return { kind: _kinds.INT, value: token.value, loc: loc(lexer, token) }; case _lexer.TokenKind.FLOAT: lexer.advance(); return { kind: _kinds.FLOAT, value: token.value, loc: loc(lexer, token) }; case _lexer.TokenKind.STRING: lexer.advance(); return { kind: _kinds.STRING, value: token.value, loc: loc(lexer, token) }; case _lexer.TokenKind.NAME: if (token.value === 'true' || token.value === 'false') { lexer.advance(); return { kind: _kinds.BOOLEAN, value: token.value === 'true', loc: loc(lexer, token) }; } else if (token.value === 'null') { lexer.advance(); return { kind: _kinds.NULL, loc: loc(lexer, token) }; } lexer.advance(); return { kind: _kinds.ENUM, value: token.value, loc: loc(lexer, token) }; case _lexer.TokenKind.DOLLAR: if (!isConst) { return parseVariable(lexer); } break; } throw unexpected(lexer); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseValueLiteral(isConst) {\n const token = this._lexer.token;\n\n switch (token.kind) {\n case TokenKind.BRACKET_L:\n return this.parseList(isConst);\n\n case TokenKind.BRACE_L:\n return this.parseObject(isConst);\n\n case TokenKind.INT:\n this._lexer.advance();\n\n ...
[ "0.70570886", "0.6685034", "0.6684451", "0.6651367", "0.6651367", "0.6651367", "0.6651367", "0.6634002", "0.65697414", "0.6566348", "0.656263", "0.656263", "0.65572596", "0.65559214", "0.64911103", "0.6485619", "0.58801836", "0.5734933", "0.57151306", "0.56862545", "0.5681436...
0.6658609
7
ListValue[Const] : [ ] [ Value[?Const]+ ]
function parseList(lexer, isConst) { var start = lexer.token; var item = isConst ? parseConstValue : parseValueValue; return { kind: _kinds.LIST, values: any(lexer, _lexer.TokenKind.BRACKET_L, item, _lexer.TokenKind.BRACKET_R), loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseList(isConst) {\n const item = () => this.parseValueLiteral(isConst);\n\n return this.node(this._lexer.token, {\n kind: Kind.LIST,\n values: this.any(TokenKind.BRACKET_L, item, TokenKind.BRACKET_R),\n });\n }", "function parseList(lexer$$1, isConst) {\n var start = lexer$$1.token;\n va...
[ "0.68530875", "0.67082024", "0.6670494", "0.663753", "0.663753", "0.663753", "0.663753", "0.663753", "0.661275", "0.661275", "0.65464705", "0.6488943", "0.6437807", "0.64054286", "0.64054286", "0.6404618", "0.6157263", "0.5797986", "0.5725365", "0.5670116", "0.5670116", "0....
0.66044474
15
ObjectField[Const] : Name : Value[?Const]
function parseObjectField(lexer, isConst) { var start = lexer.token; return { kind: _kinds.OBJECT_FIELD, name: parseName(lexer), value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, isConst)), loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseObjectField(lexer$$1, isConst) {\n var start = lexer$$1.token;\n return {\n kind: kinds.OBJECT_FIELD,\n name: parseName(lexer$$1),\n value: (expect(lexer$$1, lexer.TokenKind.COLON), parseValueLiteral(lexer$$1, isConst)),\n loc: loc(lexer$$1, start)\n };\n}", "function parseObjectFiel...
[ "0.7566483", "0.74207675", "0.7412592", "0.7334251", "0.7334251", "0.7317285", "0.7317285", "0.7317285", "0.7317285", "0.7317285", "0.7045878", "0.7023354", "0.70039093", "0.6991812", "0.6977889", "0.6977889", "0.59030527", "0.5814423", "0.5783798", "0.5783798", "0.5578437", ...
0.73163164
15
Implements the parsing rules in the Directives section. Directives : Directive+
function parseDirectives(lexer) { var directives = []; while (peek(lexer, _lexer.TokenKind.AT)) { directives.push(parseDirective(lexer)); } return directives; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function directives() {\n var i, p, pn;\n \n while (state.tokens.next.id === \"(string)\") {\n p = peek(0);\n if (p.id === \"(endline)\") {\n i = 1;\n do {\n pn = peek(i++);\n } while (pn.id === \"(endline)\");\n if (pn.id ...
[ "0.68262845", "0.6286808", "0.61456513", "0.61375785", "0.6046298", "0.6007161", "0.60071605", "0.59940124", "0.5908961", "0.5908961", "0.5908961", "0.5898839", "0.588673", "0.5848299", "0.57972956", "0.5790462", "0.5790462", "0.5785729", "0.57542944", "0.575228", "0.5745993"...
0.6020741
9
Implements the parsing rules in the Types section. Type : NamedType ListType NonNullType
function parseTypeReference(lexer) { var start = lexer.token; var type = void 0; if (skip(lexer, _lexer.TokenKind.BRACKET_L)) { type = parseTypeReference(lexer); expect(lexer, _lexer.TokenKind.BRACKET_R); type = { kind: _kinds.LIST_TYPE, type: type, loc: loc(lexer, start) }; } else { type = parseNamedType(lexer); } if (skip(lexer, _lexer.TokenKind.BANG)) { return { kind: _kinds.NON_NULL_TYPE, type: type, loc: loc(lexer, start) }; } return type; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseType(parser) {\n\t var start = parser.token.start;\n\t var type = undefined;\n\t if (skip(parser, _lexer.TokenKind.BRACKET_L)) {\n\t type = parseType(parser);\n\t expect(parser, _lexer.TokenKind.BRACKET_R);\n\t type = {\n\t kind: _kinds.LIST_TYPE,\n\t type: type,\n\t loc: l...
[ "0.6707498", "0.65781015", "0.641714", "0.6298393", "0.62269354", "0.62095207", "0.61652607", "0.6067785", "0.6067331", "0.60430384", "0.60430384", "0.60142046", "0.6012585", "0.59662765", "0.59662765", "0.59662765", "0.59662765", "0.5927915", "0.5876502", "0.5874435", "0.582...
0.60295254
16
Implements the parsing rules in the Type Definition section. TypeSystemDefinition : SchemaDefinition TypeDefinition TypeExtensionDefinition DirectiveDefinition TypeDefinition : ScalarTypeDefinition ObjectTypeDefinition InterfaceTypeDefinition UnionTypeDefinition EnumTypeDefinition InputObjectTypeDefinition
function parseTypeSystemDefinition(lexer) { if (peek(lexer, _lexer.TokenKind.NAME)) { switch (lexer.token.value) { case 'schema': return parseSchemaDefinition(lexer); case 'scalar': return parseScalarTypeDefinition(lexer); case 'type': return parseObjectTypeDefinition(lexer); case 'interface': return parseInterfaceTypeDefinition(lexer); case 'union': return parseUnionTypeDefinition(lexer); case 'enum': return parseEnumTypeDefinition(lexer); case 'input': return parseInputObjectTypeDefinition(lexer); case 'extend': return parseTypeExtensionDefinition(lexer); case 'directive': return parseDirectiveDefinition(lexer); } } throw unexpected(lexer); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseTypeSystemDefinition(lexer) {\n\t if (peek(lexer, _lexer.TokenKind.NAME)) {\n\t switch (lexer.token.value) {\n\t case 'schema':\n\t return parseSchemaDefinition(lexer);\n\t case 'scalar':\n\t return parseScalarTypeDefinition(lexer);\n\t case 'type':\n\t return ...
[ "0.76655704", "0.7429532", "0.7429532", "0.7429532", "0.7429532", "0.7425481", "0.74038315", "0.73311204", "0.726112", "0.7259963", "0.72349787", "0.72349787", "0.72287154", "0.6201402", "0.6171853", "0.61450917", "0.6008277", "0.58167905", "0.56895465", "0.56895465", "0.5681...
0.768092
4
ScalarTypeDefinition : scalar Name Directives?
function parseScalarTypeDefinition(lexer) { var start = lexer.token; expectKeyword(lexer, 'scalar'); var name = parseName(lexer); var directives = parseDirectives(lexer); return { kind: _kinds.SCALAR_TYPE_DEFINITION, name: name, directives: directives, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseScalarTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('scalar');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.SCALAR_TYPE_DEFINITION,\...
[ "0.83981085", "0.8193177", "0.8142972", "0.8129371", "0.8107919", "0.8107919", "0.8107919", "0.8107919", "0.8107919", "0.8044898", "0.8037876", "0.80359125", "0.8035722", "0.8035722", "0.8029403", "0.7966847", "0.6736141", "0.6734414", "0.6731313", "0.6731313", "0.6725698", ...
0.8139874
7
ImplementsInterfaces : implements NamedType+
function parseImplementsInterfaces(lexer) { var types = []; if (lexer.token.value === 'implements') { lexer.advance(); do { types.push(parseNamedType(lexer)); } while (peek(lexer, _lexer.TokenKind.NAME)); } return types; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseImplementsInterfaces(lexer$$1) {\n var types = [];\n if (lexer$$1.token.value === 'implements') {\n lexer$$1.advance();\n do {\n types.push(parseNamedType(lexer$$1));\n } while (peek(lexer$$1, lexer.TokenKind.NAME));\n }\n return types;\n}", "function parseImplementsInterfaces(lex...
[ "0.75167805", "0.7466684", "0.7466684", "0.73151207", "0.7131874", "0.7095719", "0.70173657", "0.7017177", "0.698607", "0.698607", "0.698607", "0.698607", "0.6984648", "0.693063", "0.693063", "0.68409795", "0.6276432", "0.61391926", "0.597205", "0.585664", "0.5825495", "0.5...
0.74047166
7
FieldDefinition : Name ArgumentsDefinition? : Type Directives?
function parseFieldDefinition(lexer) { var start = lexer.token; var name = parseName(lexer); var args = parseArgumentDefs(lexer); expect(lexer, _lexer.TokenKind.COLON); var type = parseTypeReference(lexer); var directives = parseDirectives(lexer); return { kind: _kinds.FIELD_DEFINITION, name: name, arguments: args, type: type, directives: directives, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseFieldDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n const args = this.parseArgumentDefs();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n const directives = this.parseCon...
[ "0.70443845", "0.64568156", "0.6419295", "0.6314216", "0.6285715", "0.6285715", "0.6285715", "0.6285715", "0.6285715", "0.6277438", "0.6260801", "0.6184807", "0.6102944", "0.60624665", "0.60624665", "0.6043432", "0.60264546", "0.5976885", "0.59559834", "0.59483516", "0.593776...
0.6231216
15
ArgumentsDefinition : ( InputValueDefinition+ )
function parseArgumentDefs(lexer) { if (!peek(lexer, _lexer.TokenKind.PAREN_L)) { return []; } return many(lexer, _lexer.TokenKind.PAREN_L, parseInputValueDef, _lexer.TokenKind.PAREN_R); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseArgumentDefs() {\n return this.optionalMany(\n TokenKind.PAREN_L,\n this.parseInputValueDef,\n TokenKind.PAREN_R,\n );\n }", "function parseArgumentDefs(lexer$$1) {\n if (!peek(lexer$$1, lexer.TokenKind.PAREN_L)) {\n return [];\n }\n return many(lexer$$1, lexer.TokenKind.PAREN_L,...
[ "0.6459641", "0.6177845", "0.6175874", "0.60900456", "0.60900456", "0.60688555", "0.60688555", "0.59616387", "0.5929642", "0.58954644", "0.5881806", "0.58314556", "0.58314556", "0.58064735", "0.58064735", "0.56615597", "0.5652079", "0.5644433", "0.5548949", "0.5535848", "0.55...
0.5929815
16
InputValueDefinition : Name : Type DefaultValue? Directives?
function parseInputValueDef(lexer) { var start = lexer.token; var name = parseName(lexer); expect(lexer, _lexer.TokenKind.COLON); var type = parseTypeReference(lexer); var defaultValue = null; if (skip(lexer, _lexer.TokenKind.EQUALS)) { defaultValue = parseConstValue(lexer); } var directives = parseDirectives(lexer); return { kind: _kinds.INPUT_VALUE_DEFINITION, name: name, type: type, defaultValue: defaultValue, directives: directives, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseInputValueDef() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseName();\n this.expectToken(TokenKind.COLON);\n const type = this.parseTypeReference();\n let defaultValue;\n\n if (this.expectOptionalToken(TokenKind.EQUALS)) {\n ...
[ "0.7755709", "0.73994255", "0.7284767", "0.7284767", "0.7284767", "0.7284767", "0.72812206", "0.72745436", "0.72430205", "0.71549386", "0.7082239", "0.7027068", "0.7027068", "0.70051235", "0.6944897", "0.69158816", "0.6588673", "0.62046576", "0.6169607", "0.6000942", "0.59673...
0.71953994
13
UnionTypeDefinition : union Name Directives? = UnionMembers
function parseUnionTypeDefinition(lexer) { var start = lexer.token; expectKeyword(lexer, 'union'); var name = parseName(lexer); var directives = parseDirectives(lexer); expect(lexer, _lexer.TokenKind.EQUALS); var types = parseUnionMembers(lexer); return { kind: _kinds.UNION_TYPE_DEFINITION, name: name, directives: directives, types: types, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseUnionTypeDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n this.expectKeyword('union');\n const name = this.parseName();\n const directives = this.parseConstDirectives();\n const types = this.parseUnionMemberTypes();\n return this.node(star...
[ "0.8724834", "0.8276988", "0.8275097", "0.8244607", "0.8244607", "0.8244607", "0.8244607", "0.8244607", "0.8196522", "0.8194654", "0.8190183", "0.8190183", "0.817318", "0.8033671", "0.7842884", "0.7788939", "0.7037094", "0.7014835", "0.69509476", "0.69509476", "0.69509476", ...
0.8138545
18
UnionMembers : `|`? NamedType UnionMembers | NamedType
function parseUnionMembers(lexer) { // Optional leading pipe skip(lexer, _lexer.TokenKind.PIPE); var members = []; do { members.push(parseNamedType(lexer)); } while (skip(lexer, _lexer.TokenKind.PIPE)); return members; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseUnionMembers(lexer) {\n var members = [];\n do {\n members.push(parseNamedType(lexer));\n } while (skip(lexer, _lexer.TokenKind.PIPE));\n return members;\n}", "function parseUnionMembers(lexer) {\n var members = [];\n do {\n members.push(parseNamedType(lexer));\n } while (skip(lexer, _...
[ "0.8031646", "0.8031646", "0.79166913", "0.77637833", "0.7708086", "0.7668339", "0.76194954", "0.7561891", "0.7561891", "0.7561891", "0.7561891", "0.7539163", "0.7533797", "0.741854", "0.741854", "0.7285285", "0.7002373", "0.6606566", "0.657404", "0.6554488", "0.6547767", "...
0.79965776
5
EnumValueDefinition : EnumValue Directives? EnumValue : Name
function parseEnumValueDefinition(lexer) { var start = lexer.token; var name = parseName(lexer); var directives = parseDirectives(lexer); return { kind: _kinds.ENUM_VALUE_DEFINITION, name: name, directives: directives, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseEnumValueDefinition() {\n const start = this._lexer.token;\n const description = this.parseDescription();\n const name = this.parseEnumValueName();\n const directives = this.parseConstDirectives();\n return this.node(start, {\n kind: Kind.ENUM_VALUE_DEFINITION,\n description,\n n...
[ "0.86656684", "0.8045927", "0.80225587", "0.79836", "0.7978656", "0.7978656", "0.7978656", "0.7978656", "0.7978656", "0.7911829", "0.7791489", "0.7773378", "0.776112", "0.7755505", "0.7755505", "0.7608511", "0.7397767", "0.73932606", "0.6672689", "0.66048175", "0.65508544", ...
0.7902182
14
TypeExtensionDefinition : extend ObjectTypeDefinition
function parseTypeExtensionDefinition(lexer) { var start = lexer.token; expectKeyword(lexer, 'extend'); var definition = parseObjectTypeDefinition(lexer); return { kind: _kinds.TYPE_EXTENSION_DEFINITION, definition: definition, loc: loc(lexer, start) }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "parseObjectTypeExtension() {\n const start = this._lexer.token;\n this.expectKeyword('extend');\n this.expectKeyword('type');\n const name = this.parseName();\n const interfaces = this.parseImplementsInterfaces();\n const directives = this.parseConstDirectives();\n const fields = this.parseFie...
[ "0.7657604", "0.7620609", "0.7618631", "0.7618631", "0.7618631", "0.7618631", "0.7616659", "0.7597039", "0.7567515", "0.75627995", "0.75618565", "0.75618565", "0.7561738", "0.7407404", "0.7285805", "0.7244796", "0.6554908", "0.6552588", "0.65412486", "0.65412486", "0.65412486...
0.74211496
18
DirectiveLocations : `|`? Name DirectiveLocations | Name
function parseDirectiveLocations(lexer) { // Optional leading pipe skip(lexer, _lexer.TokenKind.PIPE); var locations = []; do { locations.push(parseName(lexer)); } while (skip(lexer, _lexer.TokenKind.PIPE)); return locations; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseDirectiveLocations(lexer) {\n var locations = [];\n do {\n locations.push(parseName(lexer));\n } while (skip(lexer, _lexer.TokenKind.PIPE));\n return locations;\n}", "function parseDirectiveLocations(lexer) {\n var locations = [];\n do {\n locations.push(parseName(lexer));\n } while (s...
[ "0.7822161", "0.7822161", "0.7693688", "0.75380504", "0.7521412", "0.7399539", "0.7386918", "0.73523265", "0.73523265", "0.73523265", "0.73523265", "0.73391724", "0.733446", "0.733446", "0.7185509", "0.7163549", "0.6474554", "0.6267542", "0.62523264", "0.62413067", "0.6236664...
0.7764236
5
Core parsing utility functions Returns a location object, used to identify the place in the source that created a given parsed object.
function loc(lexer, startToken) { if (!lexer.options.noLocation) { return new Loc(startToken, lexer.lastToken, lexer.source); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function loc(parser, start) {\n\t if (parser.options.noLocation) {\n\t return null;\n\t }\n\t if (parser.options.noSource) {\n\t return { start: start, end: parser.prevEnd };\n\t }\n\t return { start: start, end: parser.prevEnd, source: parser.source };\n\t}", "function loc(parser, start) {\n if (par...
[ "0.7424325", "0.7374668", "0.64806646", "0.64806646", "0.64806646", "0.64806646", "0.64806646", "0.64806646", "0.64806646", "0.64806646", "0.64806646", "0.64806646", "0.64643985", "0.64643985", "0.64615715", "0.64243346", "0.61489433", "0.6103289", "0.6103077", "0.6103077", "...
0.6452525
28
Determines if the next token is of a given kind
function peek(lexer, kind) { return lexer.token.kind === kind; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "match(tokenKind) {\n if (this.check(tokenKind)) {\n this.current++; //advance\n return true;\n }\n return false;\n }", "isToken(type) { return this.tokenizer.isTokenType(type) }", "peek(kind) {\n return this._lexer.token.kind === kind;\n }", "isTokenType(type...
[ "0.7669077", "0.7138985", "0.71243644", "0.6991784", "0.6981886", "0.6981886", "0.69696575", "0.6958934", "0.6938066", "0.6907717", "0.6870581", "0.68650633", "0.6751013", "0.67288613", "0.6719839", "0.6683571", "0.6593374", "0.64219314", "0.636494", "0.636494", "0.63374966",...
0.70372933
16
If the next token is of the given kind, return true after advancing the lexer. Otherwise, do not change the parser state and return false.
function skip(lexer, kind) { var match = lexer.token.kind === kind; if (match) { lexer.advance(); } return match; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "match(tokenKind) {\n if (this.check(tokenKind)) {\n this.current++; //advance\n return true;\n }\n return false;\n }", "peek(kind) {\n return this._lexer.token.kind === kind;\n }", "expectOptionalToken(kind) {\n const token = this._lexer.token;\n\n if (to...
[ "0.78852", "0.689108", "0.6701221", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.66495097", "0.6525037", "0....
0.5621488
62
If the next token is of the given kind, return that token after advancing the lexer. Otherwise, do not change the parser state and throw an error.
function expect(lexer, kind) { var token = lexer.token; if (token.kind === kind) { lexer.advance(); return token; } throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function expectToken(lexer, kind) {\n var token = lexer.token;\n\n if (token.kind === kind) {\n lexer.advance();\n return token;\n }\n\n throw syntaxError(lexer.source, token.start, \"Expected \".concat(kind, \", found \").concat(getTokenDesc(token)));\n}", "function expectToken(lexer, kind) {\n var t...
[ "0.75723034", "0.7555931", "0.7541712", "0.7541712", "0.7500238", "0.7457105", "0.7457105", "0.7447638", "0.73832905", "0.7254446", "0.72139543", "0.7144362", "0.65815", "0.65815", "0.65815", "0.65815", "0.65045434", "0.64782095", "0.6416267", "0.64111257", "0.64111257", "0...
0.74866277
14
If the next token is a keyword with the given value, return that token after advancing the lexer. Otherwise, do not change the parser state and return false.
function expectKeyword(lexer, value) { var token = lexer.token; if (token.kind === _lexer.TokenKind.NAME && token.value === value) { lexer.advance(); return token; } throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected "' + value + '", found ' + (0, _lexer.getTokenDesc)(token)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function expectKeyword(lexer, value) {\n var token = lexer.token;\n\n if (token.kind === _lexer__WEBPACK_IMPORTED_MODULE_4__[\"TokenKind\"].NAME && token.value === value) {\n lexer.advance();\n return token;\n }\n\n throw Object(_error__WEBPACK_IMPORTED_MODULE_3__[\"syntaxError\"])(lexer.source, token.st...
[ "0.71878976", "0.71878976", "0.71839094", "0.7100573", "0.6948013", "0.69353074", "0.69277066", "0.69277066", "0.6917906", "0.6917906", "0.69026834", "0.69026834", "0.69026834", "0.69026834", "0.69026834", "0.6886096", "0.687529", "0.6861043", "0.68496", "0.6824084", "0.68032...
0.6977423
13
Helper function for creating an error when an unexpected lexed token is encountered.
function unexpected(lexer, atToken) { var token = atToken || lexer.token; return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function unexpectedTokenError(token, message)\n\t\t{\n\t\t\tvar msg = Messages.UnexpectedToken;\n\t\t\tif (token)\n\t\t\t{\n\t\t\t\tmsg = message ? message : (token.type === Token.EOF) ? Messages.UnexpectedEOS : (token.type === Token.Identifier) ? Messages.UnexpectedIdentifier : (token.type === Token.NumericLitera...
[ "0.7421297", "0.73534113", "0.7337508", "0.7335112", "0.7335112", "0.7331919", "0.7302289", "0.72845167", "0.7281797", "0.72380084", "0.72380084", "0.72380084", "0.72380084", "0.72380084", "0.7206929", "0.71722806", "0.71722806", "0.71534777", "0.71342266", "0.71126103", "0.6...
0.72068286
23
Returns a possibly empty list of parse nodes, determined by the parseFn. This list begins with a lex token of openKind and ends with a lex token of closeKind. Advances the parser to the next lex token after the closing token.
function any(lexer, openKind, parseFn, closeKind) { expect(lexer, openKind); var nodes = []; while (!skip(lexer, closeKind)) { nodes.push(parseFn(lexer)); } return nodes; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "many(openKind, parseFn, closeKind) {\n this.expectToken(openKind);\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n\n return nodes;\n }", "function many(parser, openKind, parseFn, closeKind) {\n\t expect(parser, openKind);\n\...
[ "0.75592375", "0.7246764", "0.7106308", "0.7074189", "0.70493615", "0.70493615", "0.7019147", "0.69976336", "0.69464284", "0.69464284", "0.6898007", "0.6898007", "0.6898007", "0.6898007", "0.6898007", "0.6898007", "0.6898007", "0.6898007", "0.6898007", "0.6898007", "0.6893209...
0.68095875
36
Returns a nonempty list of parse nodes, determined by the parseFn. This list begins with a lex token of openKind and ends with a lex token of closeKind. Advances the parser to the next lex token after the closing token.
function many(lexer, openKind, parseFn, closeKind) { expect(lexer, openKind); var nodes = [parseFn(lexer)]; while (!skip(lexer, closeKind)) { nodes.push(parseFn(lexer)); } return nodes; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "many(openKind, parseFn, closeKind) {\n this.expectToken(openKind);\n const nodes = [];\n\n do {\n nodes.push(parseFn.call(this));\n } while (!this.expectOptionalToken(closeKind));\n\n return nodes;\n }", "function many(parser, openKind, parseFn, closeKind) {\n\t expect(parser, openKind);\n\...
[ "0.7481586", "0.71831673", "0.7038837", "0.7000684", "0.7000684", "0.69779414", "0.68984693", "0.68984693", "0.68935955", "0.6872364", "0.68131495", "0.68131495", "0.6785034", "0.6785034", "0.6719043", "0.6719043", "0.6719043", "0.6719043", "0.6719043", "0.6719043", "0.671904...
0.6848527
19
Takes a Source and a UTF8 character offset, and returns the corresponding line and column as a SourceLocation. Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function getLocation(source, position) { var lineRegexp = /\r\n|[\n\r]/g; var line = 1; var column = position + 1; var match = void 0; while ((match = lineRegexp.exec(source.body)) && match.index < position) { line += 1; column = position + 1 - (match.index + match[0].length); } return { line: line, column: column }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getLocation(source, position) {\n let lastLineStart = 0;\n let line = 1;\n\n for (const match of source.body.matchAll(LineRegExp)) {\n typeof match.index === 'number' || invariant(false);\n\n if (match.index >= position) {\n break;\n }\n\n lastLineStart = match.index + match[0].length;...
[ "0.6811715", "0.67842644", "0.6733988", "0.6733988", "0.673177", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "0.67148054", "...
0.6777626
12
Given a Source object, this returns a Lexer for that source. A Lexer is a stateful stream generator in that every time it is advanced, it returns the next token in the Source. Assuming the source lexes, the final Token emitted by the lexer will be of kind EOF, after which the lexer will repeatedly return the same EOF token whenever called.
function createLexer(source, options) { var startOfFileToken = new Tok(SOF, 0, 0, 0, 0, null); var lexer = { source: source, options: options, lastToken: startOfFileToken, token: startOfFileToken, line: 1, lineStart: 0, advance: advanceLexer }; return lexer; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function Lexer(source) {\n var startOfFileToken = new _ast_mjs__WEBPACK_IMPORTED_MODULE_0__.Token(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__.TokenKind.SOF, 0, 0, 0, 0, null);\n this.source = source;\n this.lastToken = startOfFileToken;\n this.token = startOfFileToken;\n this.line = 1;\n this.lin...
[ "0.7591531", "0.7591531", "0.75848985", "0.75815326", "0.74663883", "0.74663883", "0.74663883", "0.7282543", "0.72626966", "0.72584814", "0.72547555", "0.7233765", "0.7219569", "0.7203923", "0.71246296", "0.71246296", "0.71246296", "0.71246296", "0.71246296", "0.71246296", "0...
0.73009163
11
Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function advanceLexer() { var token = this.lastToken = this.token; if (token.kind !== EOF) { do { token = token.next = readToken(this, token); } while (token.kind === COMMENT); this.token = token; } return token; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "componentDidMount() {\n // if this is the first time the home screen is loading\n // we must initialize Facebook\n if (!window.FB) {\n window.fbAsyncInit = function() {\n window.FB.init({\n appId : '280945375708713',\n cookie : true, // enable cookies to allow the s...
[ "0.59744155", "0.57182646", "0.5716308", "0.5612214", "0.5600275", "0.5545179", "0.54876554", "0.5451801", "0.5408737", "0.5384387", "0.5377831", "0.53756464", "0.53692806", "0.5342666", "0.5319401", "0.53052574", "0.5305171", "0.5263118", "0.5254797", "0.5254797", "0.5163851...
0.0
-1
A helper function to describe a token as a string for debugging
function getTokenDesc(token) { var value = token.value; return value ? token.kind + ' "' + value + '"' : token.kind; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function printToken(token) {\r\n\t\tif (token.type === 'quote') {\r\n\t\t\treturn `\"${token.token}\"`;\r\n\t\t} else {\r\n\t\t\treturn token.token;\r\n\t\t}\r\n\t}", "function getTokenDesc(token) {\n var value = token.value;\n return value ? \"\".concat(token.kind, \" \\\"\").concat(value, \"\\\"\") :...
[ "0.7346337", "0.72634125", "0.7247232", "0.7247232", "0.7237602", "0.7237602", "0.7237602", "0.7237602", "0.7237602", "0.7237602", "0.7237602", "0.7237602", "0.72264", "0.7140082", "0.71369827", "0.70759815", "0.7074039", "0.7074039", "0.7074039", "0.7074039", "0.7074039", ...
0.7213501
22
Helper function for constructing the Token object.
function Tok(kind, start, end, line, column, prev, value) { this.kind = kind; this.start = start; this.end = end; this.line = line; this.column = column; this.value = value; this.prev = prev; this.next = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function makeToken(kind, start, end, value) {\n\t return { kind: kind, start: start, end: end, value: value };\n\t}", "function makeToken(kind, start, end, value) {\n return { kind: kind, start: start, end: end, value: value };\n}", "constructor(token, type) {\n this._token = token; //token object\n ...
[ "0.716749", "0.7155585", "0.706904", "0.7064976", "0.69540286", "0.6936082", "0.6918525", "0.68987185", "0.6793239", "0.67745304", "0.6673528", "0.66003233", "0.659534", "0.649638", "0.6490552", "0.63975376", "0.6384403", "0.6367625", "0.63613516", "0.6276101", "0.6250431", ...
0.0
-1
Gets the next token from the source starting at the given position. This skips over whitespace and comments until it finds the next lexable token, then lexes punctuators immediately or calls the appropriate helper function for more complicated tokens.
function readToken(lexer, prev) { var source = lexer.source; var body = source.body; var bodyLength = body.length; var position = positionAfterWhitespace(body, prev.end, lexer); var line = lexer.line; var col = 1 + position - lexer.lineStart; if (position >= bodyLength) { return new Tok(EOF, bodyLength, bodyLength, line, col, prev); } var code = charCodeAt.call(body, position); // SourceCharacter if (code < 0x0020 && code !== 0x0009 && code !== 0x000A && code !== 0x000D) { throw (0, _error.syntaxError)(source, position, 'Cannot contain the invalid character ' + printCharCode(code) + '.'); } switch (code) { // ! case 33: return new Tok(BANG, position, position + 1, line, col, prev); // # case 35: return readComment(source, position, line, col, prev); // $ case 36: return new Tok(DOLLAR, position, position + 1, line, col, prev); // ( case 40: return new Tok(PAREN_L, position, position + 1, line, col, prev); // ) case 41: return new Tok(PAREN_R, position, position + 1, line, col, prev); // . case 46: if (charCodeAt.call(body, position + 1) === 46 && charCodeAt.call(body, position + 2) === 46) { return new Tok(SPREAD, position, position + 3, line, col, prev); } break; // : case 58: return new Tok(COLON, position, position + 1, line, col, prev); // = case 61: return new Tok(EQUALS, position, position + 1, line, col, prev); // @ case 64: return new Tok(AT, position, position + 1, line, col, prev); // [ case 91: return new Tok(BRACKET_L, position, position + 1, line, col, prev); // ] case 93: return new Tok(BRACKET_R, position, position + 1, line, col, prev); // { case 123: return new Tok(BRACE_L, position, position + 1, line, col, prev); // | case 124: return new Tok(PIPE, position, position + 1, line, col, prev); // } case 125: return new Tok(BRACE_R, position, position + 1, line, col, prev); // A-Z _ a-z case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72: case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80: case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88: case 89:case 90: case 95: case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104: case 105:case 106:case 107:case 108:case 109:case 110:case 111: case 112:case 113:case 114:case 115:case 116:case 117:case 118: case 119:case 120:case 121:case 122: return readName(source, position, line, col, prev); // - 0-9 case 45: case 48:case 49:case 50:case 51:case 52: case 53:case 54:case 55:case 56:case 57: return readNumber(source, position, code, line, col, prev); // " case 34: return readString(source, position, line, col, prev); } throw (0, _error.syntaxError)(source, position, unexpectedCharacterMessage(code)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function readToken(lexer, prev) {\n var source = lexer.source;\n var body = source.body;\n var bodyLength = body.length;\n var pos = positionAfterWhitespace(body, prev.end, lexer);\n var line = lexer.line;\n var col = 1 + pos - lexer.lineStart;\n\n if (pos >= bodyLength) {\n return new _ast_mjs__WEBPACK_...
[ "0.66196", "0.6511063", "0.6426855", "0.64120406", "0.64092094", "0.63982266", "0.63924634", "0.6377061", "0.63752246", "0.63712347", "0.63712347", "0.6352997", "0.6352997", "0.6352997", "0.6352997", "0.63496816", "0.63496816", "0.63405955", "0.63335043", "0.6321634", "0.6290...
0.63980794
10
Report a message that an unexpected character was encountered.
function unexpectedCharacterMessage(code) { if (code === 39) { // ' return 'Unexpected single quote character (\'), did you mean to use ' + 'a double quote (")?'; } return 'Cannot parse the unexpected character ' + printCharCode(code) + '.'; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function unexpectedCharacterMessage(code) {\n if (code < 0x0020 && code !== 0x0009 && code !== 0x000a && code !== 0x000d) {\n return \"Cannot contain the invalid character \".concat(printCharCode(code), \".\");\n }\n\n if (code === 39) {\n // '\n return 'Unexpected single quote ...
[ "0.708676", "0.6938613", "0.6938613", "0.6938613", "0.6938613", "0.6938613", "0.6923222", "0.68756294", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.68689543", "0.6747547", "0.67...
0.6818663
23
Reads from body starting at startPosition until it finds a nonwhitespace or commented character, then returns the position of that character for lexing.
function positionAfterWhitespace(body, startPosition, lexer) { var bodyLength = body.length; var position = startPosition; while (position < bodyLength) { var code = charCodeAt.call(body, position); // tab | space | comma | BOM if (code === 9 || code === 32 || code === 44 || code === 0xFEFF) { ++position; } else if (code === 10) { // new line ++position; ++lexer.line; lexer.lineStart = position; } else if (code === 13) { // carriage return if (charCodeAt.call(body, position + 1) === 10) { position += 2; } else { ++position; } ++lexer.line; lexer.lineStart = position; } else { break; } } return position; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function positionAfterWhitespace(body, startPosition) {\n var bodyLength = body.length;\n var position = startPosition;\n while (position < bodyLength) {\n var code = charCodeAt.call(body, position);\n // Skip Ignored\n if (\n // BOM\n code === 0xFEFF ||\n // White Space\n code === 0x0009 |...
[ "0.6905268", "0.6786167", "0.64872277", "0.641509", "0.6414316", "0.6409914", "0.6409914", "0.6409914", "0.6409914", "0.6409914", "0.6409914", "0.6409914", "0.6409914", "0.6409914", "0.63189334", "0.63189334", "0.63189334", "0.63189334", "0.63189334", "0.6287002", "0.6287002"...
0.63161314
23
Reads a comment token from the source file. [\u0009\u0020\uFFFF]
function readComment(source, start, line, col, prev) { var body = source.body; var code = void 0; var position = start; do { code = charCodeAt.call(body, ++position); } while (code !== null && ( // SourceCharacter but not LineTerminator code > 0x001F || code === 0x0009)); return new Tok(COMMENT, start, position, line, col, prev, slice.call(body, start + 1, position)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function readComment(source, start, line, col, prev) {\n var body = source.body;\n var code;\n var position = start;\n\n do {\n code = body.charCodeAt(++position);\n } while (!isNaN(code) && ( // SourceCharacter but not LineTerminator\n code > 0x001f || code === 0x0009));\n\n return new _ast_mjs__WEBPACK...
[ "0.7810849", "0.7803462", "0.7702474", "0.76968354", "0.7681165", "0.7681165", "0.75763005", "0.75763005", "0.75763005", "0.7535053", "0.7519027", "0.7504508", "0.7503649", "0.7502324", "0.7487181", "0.7487181", "0.7474933", "0.7474933", "0.7474933", "0.74702376", "0.74702376...
0.7506334
16
Reads a number token from the source file, either a float or an int depending on whether a decimal point appears. Int: ?(0|[19][09]) Float: ?(0|[19][09])(\.[09]+)?((E|e)(+|)?[09]+)?
function readNumber(source, start, firstCode, line, col, prev) { var body = source.body; var code = firstCode; var position = start; var isFloat = false; if (code === 45) { // - code = charCodeAt.call(body, ++position); } if (code === 48) { // 0 code = charCodeAt.call(body, ++position); if (code >= 48 && code <= 57) { throw (0, _error.syntaxError)(source, position, 'Invalid number, unexpected digit after 0: ' + printCharCode(code) + '.'); } } else { position = readDigits(source, position, code); code = charCodeAt.call(body, position); } if (code === 46) { // . isFloat = true; code = charCodeAt.call(body, ++position); position = readDigits(source, position, code); code = charCodeAt.call(body, position); } if (code === 69 || code === 101) { // E e isFloat = true; code = charCodeAt.call(body, ++position); if (code === 43 || code === 45) { // + - code = charCodeAt.call(body, ++position); } position = readDigits(source, position, code); } return new Tok(isFloat ? FLOAT : INT, start, position, line, col, prev, slice.call(body, start, position)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function readNumber(source, start, firstCode, line, col, prev) {\n var body = source.body;\n var code = firstCode;\n var position = start;\n var isFloat = false;\n\n if (code === 45) {\n // -\n code = body.charCodeAt(++position);\n }\n\n if (code === 48) {\n // 0\n code = body.charCodeAt(++posit...
[ "0.78587884", "0.78396785", "0.7838272", "0.78292435", "0.7799872", "0.7799872", "0.7792799", "0.7792799", "0.7792799", "0.7785889", "0.7785889", "0.7770525", "0.7765655", "0.7757538", "0.77409196", "0.77207166", "0.7640692", "0.7633159", "0.7633159", "0.7633159", "0.7633159"...
0.75973195
28
Returns the new position in the source after reading digits.
function readDigits(source, start, firstCode) { var body = source.body; var position = start; var code = firstCode; if (code >= 48 && code <= 57) { // 0 - 9 do { code = charCodeAt.call(body, ++position); } while (code >= 48 && code <= 57); // 0 - 9 return position; } throw (0, _error.syntaxError)(source, position, 'Invalid number, expected digit but got: ' + printCharCode(code) + '.'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function readDigits(source, start, firstCode) {\n var body = source.body;\n var position = start;\n var code = firstCode;\n\n if (code >= 48 && code <= 57) {\n // 0 - 9\n do {\n code = body.charCodeAt(++position);\n } while (code >= 48 && code <= 57); // 0 - 9\n\n\...
[ "0.62889117", "0.6220681", "0.6220681", "0.6196409", "0.6166372", "0.6166372", "0.6148771", "0.61461264", "0.6117102", "0.6117102", "0.60756713", "0.60660464", "0.60437703", "0.60437703", "0.60233366", "0.60233366", "0.60233366", "0.60233366", "0.60049325", "0.6004479", "0.60...
0.5866001
41
Converts four hexidecimal chars to the integer that the string represents. For example, uniCharCode('0','0','0','f') will return 15, and uniCharCode('0','0','f','f') returns 255. Returns a negative number on error, if a char was invalid. This is implemented by noting that char2hex() returns 1 on error, which means the result of ORing the char2hex() will also be negative.
function uniCharCode(a, b, c, d) { return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function uniCharCode(a, b, c, d) {\n return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);\n }", "function uniCharCode(a, b, c, d) {\n\t return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);\n\t}", "function uniCharCode(a, b, c, d) {\n\t return char2hex...
[ "0.7207237", "0.7145425", "0.7145425", "0.7145425", "0.62008524", "0.61733305", "0.6081283", "0.6069486", "0.5981487", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0.59763354", "0....
0.7250276
27
Converts a hex character to its integer value. '0' becomes 0, '9' becomes 9 'A' becomes 10, 'F' becomes 15 'a' becomes 10, 'f' becomes 15 Returns 1 on error.
function char2hex(a) { return a >= 48 && a <= 57 ? a - 48 : // 0-9 a >= 65 && a <= 70 ? a - 55 : // A-F a >= 97 && a <= 102 ? a - 87 : // a-f -1; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function hexstr2int(str)\n{\n\tvar i = 0;\n\tif (is_hexdigit(str)==true) i = parseInt(str, [16]);\n\treturn i;\n}", "function hexadecimalToInteger(string) {\n const DIGITS = {1:1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9,\n a: 10, b: 11, c: 12, d: 13, e: 14, f: 15 };\n\n string = string.toLowerCase();...
[ "0.7508741", "0.72283804", "0.717412", "0.7168694", "0.7085682", "0.699381", "0.6980311", "0.69130033", "0.68920314", "0.68048424", "0.6727937", "0.6704013", "0.66991895", "0.66991895", "0.66991895", "0.66991895", "0.66991895", "0.66991895", "0.66991895", "0.66991895", "0.669...
0.64676064
95
Reads an alphanumeric + underscore name from the source. [_AZaz][_09AZaz]
function readName(source, position, line, col, prev) { var body = source.body; var bodyLength = body.length; var end = position + 1; var code = 0; while (end !== bodyLength && (code = charCodeAt.call(body, end)) !== null && (code === 95 || // _ code >= 48 && code <= 57 || // 0-9 code >= 65 && code <= 90 || // A-Z code >= 97 && code <= 122 // a-z )) { ++end; } return new Tok(NAME, position, end, line, col, prev, slice.call(body, position, end)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function tryReadVariableName(input, index) {\t\n\t/* Need to start with a letter or underscore. */\n\tif (!/[A-Za-z_]/.test(input.charAt(index))) return null;\n\n\t/* Keep reading characters while it's possible to do so. */\t\n\tvar result = \"\";\n\twhile (/[A-Za-z_0-9]/.test(input.charAt(index))) {\n\t\tresult +...
[ "0.69242716", "0.69093364", "0.6829715", "0.6829715", "0.6829715", "0.68044996", "0.6583544", "0.6545397", "0.6524183", "0.6524183", "0.6473978", "0.64677435", "0.6454978", "0.64251363", "0.64251363", "0.64251363", "0.63683015", "0.63683015", "0.63683015", "0.63683015", "0.63...
0.62343794
31
Provided two types, return true if the types are equal (invariant).
function isEqualType(typeA, typeB) { // Equivalent types are equal. if (typeA === typeB) { return true; } // If either type is non-null, the other must also be non-null. if (typeA instanceof _definition.GraphQLNonNull && typeB instanceof _definition.GraphQLNonNull) { return isEqualType(typeA.ofType, typeB.ofType); } // If either type is a list, the other must also be a list. if (typeA instanceof _definition.GraphQLList && typeB instanceof _definition.GraphQLList) { return isEqualType(typeA.ofType, typeB.ofType); } // Otherwise the types are not equal. return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isEqualType(typeA, typeB) {\n // Equivalent types are equal.\n if (typeA === typeB) {\n return true;\n } // If either type is non-null, the other must also be non-null.\n\n\n if (Object(_type_definition__WEBPACK_IMPORTED_MODULE_0__[\"isNonNullType\"])(typeA) && Object(_type_definition__WEBPACK_IMPO...
[ "0.78690815", "0.78614306", "0.78614306", "0.7741279", "0.77284634", "0.77284634", "0.75668633", "0.73945886", "0.7276147", "0.72717834", "0.7160362", "0.6939826", "0.6927101", "0.6925228", "0.6887554", "0.6848216", "0.68359655", "0.6759086", "0.674676", "0.6740973", "0.67315...
0.7463797
9
Provided a type and a super type, return true if the first type is either equal or a subset of the second super type (covariant). Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function isTypeSubTypeOf(schema, maybeSubType, superType) { // Equivalent type is a valid subtype if (maybeSubType === superType) { return true; } // If superType is non-null, maybeSubType must also be non-null. if (superType instanceof _definition.GraphQLNonNull) { if (maybeSubType instanceof _definition.GraphQLNonNull) { return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); } return false; } else if (maybeSubType instanceof _definition.GraphQLNonNull) { // If superType is nullable, maybeSubType may be non-null or nullable. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); } // If superType type is a list, maybeSubType type must also be a list. if (superType instanceof _definition.GraphQLList) { if (maybeSubType instanceof _definition.GraphQLList) { return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); } return false; } else if (maybeSubType instanceof _definition.GraphQLList) { // If superType is not a list, maybeSubType must also be not a list. return false; } // If superType type is an abstract type, maybeSubType type may be a currently // possible object type. if ((0, _definition.isAbstractType)(superType) && maybeSubType instanceof _definition.GraphQLObjectType && schema.isPossibleType(superType, maybeSubType)) { return true; } // Otherwise, the child type is not a valid subtype of the parent type. return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isTypeSubTypeOf(schema, maybeSubType, superType) {\n\t // Equivalent type is a valid subtype\n\t if (maybeSubType === superType) {\n\t return true;\n\t }\n\n\t // If superType is non-null, maybeSubType must also be non-null.\n\t if (superType instanceof _definition.GraphQLNonNull) {\n\t if (may...
[ "0.6361967", "0.6354921", "0.6277695", "0.6277695", "0.62642574", "0.62472326", "0.6220855", "0.6220855", "0.62057275", "0.6173688", "0.6173208", "0.61647755", "0.61640644", "0.6134104", "0.61242557", "0.6121877", "0.61107874", "0.6105485", "0.61054015", "0.6093324", "0.60783...
0.63752544
2
Provided two composite types, determine if they "overlap". Two composite types overlap when the Sets of possible concrete types for each intersect. This is often used to determine if a fragment of a given type could possibly be visited in a context of another type. This function is commutative.
function doTypesOverlap(schema, typeA, typeB) { // So flow is aware this is constant var _typeB = typeB; // Equivalent types overlap if (typeA === _typeB) { return true; } if ((0, _definition.isAbstractType)(typeA)) { if ((0, _definition.isAbstractType)(_typeB)) { // If both types are abstract, then determine if there is any intersection // between possible concrete types of each. return schema.getPossibleTypes(typeA).some(function (type) { return schema.isPossibleType(_typeB, type); }); } // Determine if the latter type is a possible concrete type of the former. return schema.isPossibleType(typeA, _typeB); } if ((0, _definition.isAbstractType)(_typeB)) { // Determine if the former type is a possible concrete type of the latter. return schema.isPossibleType(_typeB, typeA); } // Otherwise the types do not overlap. return false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function doTypesOverlap(typeA, typeB) {\n\t // So flow is aware this is constant\n\t var _typeB = typeB;\n\n\t // Equivalent types overlap\n\t if (typeA === _typeB) {\n\t return true;\n\t }\n\n\t if (typeA instanceof _typeDefinition.GraphQLInterfaceType || typeA instanceof _typeDefinition.GraphQLUnionType...
[ "0.75189465", "0.7411938", "0.7224915", "0.7224915", "0.7219089", "0.71789837", "0.71789837", "0.7172623", "0.666959", "0.6415173", "0.64075595", "0.63233733", "0.6220791", "0.61632097", "0.6154309", "0.6151031", "0.6147303", "0.60793185", "0.60793185", "0.60793185", "0.60793...
0.72026366
7
Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function buildWrappedType(innerType, inputTypeNode) { if (inputTypeNode.kind === Kind.LIST_TYPE) { return new _definition.GraphQLList(buildWrappedType(innerType, inputTypeNode.type)); } if (inputTypeNode.kind === Kind.NON_NULL_TYPE) { var wrappedType = buildWrappedType(innerType, inputTypeNode.type); !!(wrappedType instanceof _definition.GraphQLNonNull) ? (0, _invariant2.default)(0, 'No nesting nonnull.') : void 0; return new _definition.GraphQLNonNull(wrappedType); } return innerType; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "componentDidMount() {\n // if this is the first time the home screen is loading\n // we must initialize Facebook\n if (!window.FB) {\n window.fbAsyncInit = function() {\n window.FB.init({\n appId : '280945375708713',\n cookie : true, // enable cookies to allow the s...
[ "0.5976053", "0.57203424", "0.57181513", "0.5614843", "0.56018084", "0.55464816", "0.54893225", "0.5453807", "0.5409828", "0.53852314", "0.5378477", "0.53759915", "0.537015", "0.53436714", "0.53220254", "0.53067243", "0.5306326", "0.5264811", "0.5253494", "0.5253494", "0.5162...
0.0
-1
This takes the ast of a schema document produced by the parse function in src/language/parser.js. If no schema definition is provided, then it will look for types named Query and Mutation. Given that AST it constructs a GraphQLSchema. The resulting schema has no resolve methods, so execution will use default resolvers.
function buildASTSchema(ast) { if (!ast || ast.kind !== Kind.DOCUMENT) { throw new Error('Must provide a document ast.'); } var schemaDef = void 0; var typeDefs = []; var nodeMap = Object.create(null); var directiveDefs = []; for (var i = 0; i < ast.definitions.length; i++) { var d = ast.definitions[i]; switch (d.kind) { case Kind.SCHEMA_DEFINITION: if (schemaDef) { throw new Error('Must provide only one schema definition.'); } schemaDef = d; break; case Kind.SCALAR_TYPE_DEFINITION: case Kind.OBJECT_TYPE_DEFINITION: case Kind.INTERFACE_TYPE_DEFINITION: case Kind.ENUM_TYPE_DEFINITION: case Kind.UNION_TYPE_DEFINITION: case Kind.INPUT_OBJECT_TYPE_DEFINITION: var typeName = d.name.value; if (nodeMap[typeName]) { throw new Error('Type "' + typeName + '" was defined more than once.'); } typeDefs.push(d); nodeMap[typeName] = d; break; case Kind.DIRECTIVE_DEFINITION: directiveDefs.push(d); break; } } var queryTypeName = void 0; var mutationTypeName = void 0; var subscriptionTypeName = void 0; if (schemaDef) { schemaDef.operationTypes.forEach(function (operationType) { var typeName = operationType.type.name.value; if (operationType.operation === 'query') { if (queryTypeName) { throw new Error('Must provide only one query type in schema.'); } if (!nodeMap[typeName]) { throw new Error('Specified query type "' + typeName + '" not found in document.'); } queryTypeName = typeName; } else if (operationType.operation === 'mutation') { if (mutationTypeName) { throw new Error('Must provide only one mutation type in schema.'); } if (!nodeMap[typeName]) { throw new Error('Specified mutation type "' + typeName + '" not found in document.'); } mutationTypeName = typeName; } else if (operationType.operation === 'subscription') { if (subscriptionTypeName) { throw new Error('Must provide only one subscription type in schema.'); } if (!nodeMap[typeName]) { throw new Error('Specified subscription type "' + typeName + '" not found in document.'); } subscriptionTypeName = typeName; } }); } else { if (nodeMap.Query) { queryTypeName = 'Query'; } if (nodeMap.Mutation) { mutationTypeName = 'Mutation'; } if (nodeMap.Subscription) { subscriptionTypeName = 'Subscription'; } } if (!queryTypeName) { throw new Error('Must provide schema definition with query type or a type named Query.'); } var innerTypeMap = { String: _scalars.GraphQLString, Int: _scalars.GraphQLInt, Float: _scalars.GraphQLFloat, Boolean: _scalars.GraphQLBoolean, ID: _scalars.GraphQLID, __Schema: _introspection.__Schema, __Directive: _introspection.__Directive, __DirectiveLocation: _introspection.__DirectiveLocation, __Type: _introspection.__Type, __Field: _introspection.__Field, __InputValue: _introspection.__InputValue, __EnumValue: _introspection.__EnumValue, __TypeKind: _introspection.__TypeKind }; var types = typeDefs.map(function (def) { return typeDefNamed(def.name.value); }); var directives = directiveDefs.map(getDirective); // If specified directives were not explicitly declared, add them. if (!directives.some(function (directive) { return directive.name === 'skip'; })) { directives.push(_directives.GraphQLSkipDirective); } if (!directives.some(function (directive) { return directive.name === 'include'; })) { directives.push(_directives.GraphQLIncludeDirective); } if (!directives.some(function (directive) { return directive.name === 'deprecated'; })) { directives.push(_directives.GraphQLDeprecatedDirective); } return new _schema.GraphQLSchema({ query: getObjectType(nodeMap[queryTypeName]), mutation: mutationTypeName ? getObjectType(nodeMap[mutationTypeName]) : null, subscription: subscriptionTypeName ? getObjectType(nodeMap[subscriptionTypeName]) : null, types: types, directives: directives, astNode: schemaDef }); function getDirective(directiveNode) { return new _directives.GraphQLDirective({ name: directiveNode.name.value, description: getDescription(directiveNode), locations: directiveNode.locations.map(function (node) { return node.value; }), args: directiveNode.arguments && makeInputValues(directiveNode.arguments), astNode: directiveNode }); } function getObjectType(typeNode) { var type = typeDefNamed(typeNode.name.value); !(type instanceof _definition.GraphQLObjectType) ? (0, _invariant2.default)(0, 'AST must provide object type.') : void 0; return type; } function produceType(typeNode) { var typeName = getNamedTypeNode(typeNode).name.value; var typeDef = typeDefNamed(typeName); return buildWrappedType(typeDef, typeNode); } function produceInputType(typeNode) { return (0, _definition.assertInputType)(produceType(typeNode)); } function produceOutputType(typeNode) { return (0, _definition.assertOutputType)(produceType(typeNode)); } function produceObjectType(typeNode) { var type = produceType(typeNode); !(type instanceof _definition.GraphQLObjectType) ? (0, _invariant2.default)(0, 'Expected Object type.') : void 0; return type; } function produceInterfaceType(typeNode) { var type = produceType(typeNode); !(type instanceof _definition.GraphQLInterfaceType) ? (0, _invariant2.default)(0, 'Expected Interface type.') : void 0; return type; } function typeDefNamed(typeName) { if (!innerTypeMap[typeName]) { if (!nodeMap[typeName]) { throw new Error('Type "' + typeName + '" not found in document.'); } innerTypeMap[typeName] = makeSchemaDef(nodeMap[typeName]); } return innerTypeMap[typeName]; } function makeSchemaDef(def) { switch (def.kind) { case Kind.OBJECT_TYPE_DEFINITION: return makeTypeDef(def); case Kind.INTERFACE_TYPE_DEFINITION: return makeInterfaceDef(def); case Kind.ENUM_TYPE_DEFINITION: return makeEnumDef(def); case Kind.UNION_TYPE_DEFINITION: return makeUnionDef(def); case Kind.SCALAR_TYPE_DEFINITION: return makeScalarDef(def); case Kind.INPUT_OBJECT_TYPE_DEFINITION: return makeInputObjectDef(def); default: throw new Error('Type kind "' + def.kind + '" not supported.'); } } function makeTypeDef(def) { var typeName = def.name.value; return new _definition.GraphQLObjectType({ name: typeName, description: getDescription(def), fields: function fields() { return makeFieldDefMap(def); }, interfaces: function interfaces() { return makeImplementedInterfaces(def); }, astNode: def }); } function makeFieldDefMap(def) { return (0, _keyValMap2.default)(def.fields, function (field) { return field.name.value; }, function (field) { return { type: produceOutputType(field.type), description: getDescription(field), args: makeInputValues(field.arguments), deprecationReason: getDeprecationReason(field), astNode: field }; }); } function makeImplementedInterfaces(def) { return def.interfaces && def.interfaces.map(function (iface) { return produceInterfaceType(iface); }); } function makeInputValues(values) { return (0, _keyValMap2.default)(values, function (value) { return value.name.value; }, function (value) { var type = produceInputType(value.type); return { type: type, description: getDescription(value), defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type), astNode: value }; }); } function makeInterfaceDef(def) { return new _definition.GraphQLInterfaceType({ name: def.name.value, description: getDescription(def), fields: function fields() { return makeFieldDefMap(def); }, astNode: def, resolveType: cannotExecuteSchema }); } function makeEnumDef(def) { return new _definition.GraphQLEnumType({ name: def.name.value, description: getDescription(def), values: (0, _keyValMap2.default)(def.values, function (enumValue) { return enumValue.name.value; }, function (enumValue) { return { description: getDescription(enumValue), deprecationReason: getDeprecationReason(enumValue), astNode: enumValue }; }), astNode: def }); } function makeUnionDef(def) { return new _definition.GraphQLUnionType({ name: def.name.value, description: getDescription(def), types: def.types.map(function (t) { return produceObjectType(t); }), resolveType: cannotExecuteSchema, astNode: def }); } function makeScalarDef(def) { return new _definition.GraphQLScalarType({ name: def.name.value, description: getDescription(def), astNode: def, serialize: function serialize() { return null; }, // Note: validation calls the parse functions to determine if a // literal value is correct. Returning null would cause use of custom // scalars to always fail validation. Returning false causes them to // always pass validation. parseValue: function parseValue() { return false; }, parseLiteral: function parseLiteral() { return false; } }); } function makeInputObjectDef(def) { return new _definition.GraphQLInputObjectType({ name: def.name.value, description: getDescription(def), fields: function fields() { return makeInputValues(def.fields); }, astNode: def }); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buildASTSchema(ast, queryTypeName, mutationTypeName, subscriptionTypeName) {\n if (!ast) {\n throw new Error('must pass in ast');\n }\n\n if (!queryTypeName) {\n throw new Error('must pass in query type');\n }\n\n var typeDefs = [];\n for (var i = 0; i < ast.definitions.length; i++) {\n var...
[ "0.7254094", "0.7240163", "0.6933867", "0.6685793", "0.6683432", "0.66662264", "0.6202912", "0.61750543", "0.61750543", "0.589635", "0.5892799", "0.58475107", "0.58112156", "0.580195", "0.57845336", "0.57807153", "0.57781076", "0.57781076", "0.5749815", "0.5749815", "0.574981...
0.6683432
5
Given a field or enum value node, returns the string value for the deprecation reason.
function getDeprecationReason(node) { var deprecated = (0, _values.getDirectiveValues)(_directives.GraphQLDeprecatedDirective, node); return deprecated && deprecated.reason; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getDeprecationReason(node) {\n const deprecated = getDirectiveValues(GraphQLDeprecatedDirective, node);\n return deprecated?.reason;\n}", "function getDeprecationReason(node) {\n var deprecated = Object(_execution_values__WEBPACK_IMPORTED_MODULE_10__[\"getDirectiveValues\"])(_type_directives__WEBPACK...
[ "0.6877404", "0.68008965", "0.67468244", "0.67468244", "0.65902656", "0.6589046", "0.54048896", "0.531125", "0.5104271", "0.5104271", "0.4844287", "0.4831502", "0.4787977", "0.47721902", "0.47710094", "0.47080436", "0.47080436", "0.46951747", "0.46883467", "0.46592876", "0.46...
0.6785109
3
Given an ast node, returns its string description based on a contiguous block fullline of comments preceding it.
function getDescription(node) { var loc = node.loc; if (!loc) { return; } var comments = []; var minSpaces = void 0; var token = loc.startToken.prev; while (token && token.kind === _lexer.TokenKind.COMMENT && token.next && token.prev && token.line + 1 === token.next.line && token.line !== token.prev.line) { var value = String(token.value); var spaces = leadingSpaces(value); if (minSpaces === undefined || spaces < minSpaces) { minSpaces = spaces; } comments.push(value); token = token.prev; } return comments.reverse().map(function (comment) { return comment.slice(minSpaces); }).join('\n'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getDescription(node) {\n\t var loc = node.loc;\n\t if (!loc) {\n\t return;\n\t }\n\t var comments = [];\n\t var minSpaces = void 0;\n\t var token = loc.startToken.prev;\n\t while (token && token.kind === _lexer.TokenKind.COMMENT && token.next && token.prev && token.line + 1 === token.next.line &...
[ "0.66516316", "0.61217594", "0.6119501", "0.6119501", "0.608099", "0.6031577", "0.5845183", "0.58301175", "0.58301175", "0.57097083", "0.5699353", "0.5579826", "0.5526438", "0.5525686", "0.5504061", "0.5497301", "0.5489087", "0.54602695", "0.54288703", "0.54288703", "0.542493...
0.6720467
2
A helper function to build a GraphQLSchema directly from a source document.
function buildSchema(source) { return buildASTSchema((0, _parser.parse)(source)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buildSchema(source) {\n\t return buildASTSchema((0, _parser.parse)(source));\n\t}", "function buildSchema(source, options) {\n var document = (0, _parser.parse)(source, {\n noLocation: options === null || options === void 0 ? void 0 : options.noLocation,\n allowLegacySDLEmptyFields: options === ...
[ "0.7696594", "0.74385685", "0.74385685", "0.7430873", "0.7430873", "0.7270707", "0.6659614", "0.6568555", "0.65323377", "0.64452153", "0.64452153", "0.6437725", "0.63612807", "0.60894394", "0.60894394", "0.6076323", "0.6032237", "0.58776057", "0.5717966", "0.5705632", "0.5697...
0.7711342
2
Count the number of spaces on the starting side of a string.
function leadingSpaces(str) { var i = 0; for (; i < str.length; i++) { if (str[i] !== ' ') { break; } } return i; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function countNonSpaces(str){\n return str.split(\" \").join(\"\").length;\n}", "function leadingSpaces(str) {\n\t var i = 0;\n\t for (; i < str.length; i++) {\n\t if (str[i] !== ' ') {\n\t break;\n\t }\n\t }\n\t return i;\n\t}", "function Count(str) {\n let total = 0;\n for (let i=0; i...
[ "0.74004203", "0.7092836", "0.7039084", "0.66203", "0.6613388", "0.6571844", "0.64921933", "0.6492072", "0.6451234", "0.6398698", "0.63981014", "0.635353", "0.63483375", "0.6343213", "0.6343213", "0.6343213", "0.63416266", "0.6267387", "0.6267387", "0.6267387", "0.6267387", ...
0.70255387
5
Given a JavaScript value and a GraphQL type, determine if the value will be accepted for that type. This is primarily useful for validating the runtime values of query variables.
function isValidJSValue(value, type) { // A value must be provided if the type is non-null. if (type instanceof _definition.GraphQLNonNull) { if ((0, _isNullish2.default)(value)) { return ['Expected "' + String(type) + '", found null.']; } return isValidJSValue(value, type.ofType); } if ((0, _isNullish2.default)(value)) { return []; } // Lists accept a non-list value as a list of one. if (type instanceof _definition.GraphQLList) { var itemType = type.ofType; if ((0, _iterall.isCollection)(value)) { var errors = []; (0, _iterall.forEach)(value, function (item, index) { errors.push.apply(errors, isValidJSValue(item, itemType).map(function (error) { return 'In element #' + index + ': ' + error; })); }); return errors; } return isValidJSValue(value, itemType); } // Input objects check each defined field. if (type instanceof _definition.GraphQLInputObjectType) { if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object' || value === null) { return ['Expected "' + type.name + '", found not an object.']; } var fields = type.getFields(); var _errors = []; // Ensure every provided field is defined. Object.keys(value).forEach(function (providedField) { if (!fields[providedField]) { _errors.push('In field "' + providedField + '": Unknown field.'); } }); // Ensure every defined field is valid. Object.keys(fields).forEach(function (fieldName) { var newErrors = isValidJSValue(value[fieldName], fields[fieldName].type); _errors.push.apply(_errors, newErrors.map(function (error) { return 'In field "' + fieldName + '": ' + error; })); }); return _errors; } !(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType) ? (0, _invariant2.default)(0, 'Must be input type') : void 0; // Scalar/Enum input checks to ensure the type can parse the value to // a non-null value. try { var parseResult = type.parseValue(value); if ((0, _isNullish2.default)(parseResult) && !type.isValidValue(value)) { return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + '.']; } } catch (error) { return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + ': ' + error.message]; } return []; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isValidValue(type: GraphQLType, value: any): boolean {\n if (type instanceof GraphQLNonNull) {\n if (isNullish(value)) {\n return false;\n }\n return isValidValue(type.ofType, value);\n }\n\n if (isNullish(value)) {\n return true;\n }\n\n if (type instanceof GraphQLList) {\n var i...
[ "0.70804834", "0.6853694", "0.678221", "0.6651158", "0.6446671", "0.6446671", "0.6446671", "0.63790476", "0.6345396", "0.6345396", "0.6345396", "0.6345396", "0.6281204", "0.6281204", "0.62769157", "0.6257103", "0.6255925", "0.62558407", "0.61459804", "0.6100574", "0.6098811",...
0.67015237
4
Utility for validators which determines if a value literal node is valid given an input type. Note that this only validates literal values, variables are assumed to provide values of the correct type.
function isValidLiteralValue(type, valueNode) { // A value must be provided if the type is non-null. if (type instanceof _definition.GraphQLNonNull) { if (!valueNode || valueNode.kind === Kind.NULL) { return ['Expected "' + String(type) + '", found null.']; } return isValidLiteralValue(type.ofType, valueNode); } if (!valueNode || valueNode.kind === Kind.NULL) { return []; } // This function only tests literals, and assumes variables will provide // values of the correct type. if (valueNode.kind === Kind.VARIABLE) { return []; } // Lists accept a non-list value as a list of one. if (type instanceof _definition.GraphQLList) { var itemType = type.ofType; if (valueNode.kind === Kind.LIST) { return valueNode.values.reduce(function (acc, item, index) { var errors = isValidLiteralValue(itemType, item); return acc.concat(errors.map(function (error) { return 'In element #' + index + ': ' + error; })); }, []); } return isValidLiteralValue(itemType, valueNode); } // Input objects check each defined field and look for undefined fields. if (type instanceof _definition.GraphQLInputObjectType) { if (valueNode.kind !== Kind.OBJECT) { return ['Expected "' + type.name + '", found not an object.']; } var fields = type.getFields(); var errors = []; // Ensure every provided field is defined. var fieldNodes = valueNode.fields; fieldNodes.forEach(function (providedFieldNode) { if (!fields[providedFieldNode.name.value]) { errors.push('In field "' + providedFieldNode.name.value + '": Unknown field.'); } }); // Ensure every defined field is valid. var fieldNodeMap = (0, _keyMap2.default)(fieldNodes, function (fieldNode) { return fieldNode.name.value; }); Object.keys(fields).forEach(function (fieldName) { var result = isValidLiteralValue(fields[fieldName].type, fieldNodeMap[fieldName] && fieldNodeMap[fieldName].value); errors.push.apply(errors, result.map(function (error) { return 'In field "' + fieldName + '": ' + error; })); }); return errors; } !(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType) ? (0, _invariant2.default)(0, 'Must be input type') : void 0; // Scalars determine if a literal values is valid. if (!type.isValidLiteral(valueNode)) { return ['Expected type "' + type.name + '", found ' + (0, _printer.print)(valueNode) + '.']; } return []; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isValidLiteralValue(type, valueNode) {\n // A value must be provided if the type is non-null.\n if (type instanceof _definition.GraphQLNonNull) {\n if (!valueNode || valueNode.kind === _kinds.NULL) {\n return ['Expected \"' + String(type) + '\", found null.'];\n }\n return isValidLiteralVa...
[ "0.7644156", "0.75535417", "0.73288494", "0.72017807", "0.6699415", "0.6667568", "0.6541552", "0.6541552", "0.6463026", "0.6357233", "0.6256124", "0.6239035", "0.62073034", "0.62073034", "0.6180327", "0.61644083", "0.6067311", "0.60612154", "0.6002638", "0.5965178", "0.593982...
0.7636621
2
Not exactly the same as the executor's definition of getFieldDef, in this statically evaluated environment we do not always have an Object type, and need to handle Interface and Union types.
function getFieldDef(schema, parentType, fieldNode) { var name = fieldNode.name.value; if (name === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) { return _introspection.SchemaMetaFieldDef; } if (name === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) { return _introspection.TypeMetaFieldDef; } if (name === _introspection.TypeNameMetaFieldDef.name && (0, _definition.isCompositeType)(parentType)) { return _introspection.TypeNameMetaFieldDef; } if (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType) { return parentType.getFields()[name]; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getFieldDef(schema, parentType, fieldNode) {\n var name = fieldNode.name.value;\n\n if (name === _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_5__[\"SchemaMetaFieldDef\"].name && schema.getQueryType() === parentType) {\n return _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_5__[\"SchemaMetaField...
[ "0.6583673", "0.6583673", "0.65033096", "0.6456063", "0.6449472", "0.64401114", "0.64401114", "0.6414258", "0.6369705", "0.63316613", "0.6330788", "0.6319507", "0.63099563", "0.6303175", "0.62634933", "0.6257171", "0.6210179", "0.6194197", "0.6133457", "0.6121138", "0.6113981...
0.6289813
15
Output a newline to the buffer.
function cr() { if (this.lastOut !== '\n') { this.lit('\n'); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cr() {\n if (this.lastOut !== '\\n') {\n this.lit('\\n');\n }\n }", "function sc_newline(p) {\n if (p === undefined) // we assume not given\n\tp = SC_DEFAULT_OUT;\n p.appendJSString(\"\\n\");\n}", "function writeln(str)\n{\n\twrite(str + \"\\r\\n\");\n}", "function newLine() {\n ...
[ "0.68626684", "0.646926", "0.6364287", "0.62537265", "0.62073195", "0.61951905", "0.61894673", "0.61886406", "0.6188402", "0.61088437", "0.6071579", "0.606194", "0.6021159", "0.5928647", "0.5887326", "0.5816335", "0.5705863", "0.56727886", "0.5629288", "0.558298", "0.55758154...
0.6761441
2
inlined Object.is polyfill to avoid requiring consumers ship their own /eslintdisable noselfcompare
function is(x, y) { // SameValue algorithm if (x === y) { // Steps 1-5, 7-10 // Steps 6.b-6.e: +0 != -0 return x !== 0 || 1 / x === 1 / y; } else { // Step 6.a: NaN == NaN return x !== x && y !== y; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isObject$1(obj) {\n // incase of arrow function and array\n return Object(obj) === obj && String(obj) === '[object Object]' && !isFunction(obj) && !isArray(obj);\n }", "function isObject$1(obj) {\n ...
[ "0.673139", "0.6633761", "0.6610435", "0.65997535", "0.65996826", "0.6565089", "0.6506278", "0.6468222", "0.6462761", "0.64114064", "0.63700455", "0.6365079", "0.6365079", "0.6365079", "0.6365079", "0.6356776", "0.63271695", "0.6322019", "0.63218695", "0.62953717", "0.6295371...
0.0
-1
Equivalent of `typeof` but with special handling for array and regexp.
function getPropType(propValue) { var propType = typeof propValue; if (Array.isArray(propValue)) { return 'array'; } if (propValue instanceof RegExp) { // Old webkits (at least until Android 4.0) return 'function' rather than // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ // passes PropTypes.object. return 'object'; } if (isSymbol(propType, propValue)) { return 'symbol'; } return propType; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function sc_typeof( x ) {\n return typeof x;\n}", "static type(arg)\n {\n const types = [\n 'array', 'boolean', 'function', 'number',\n 'null', 'object', 'regexp', 'symbol', 'string',\n 'undefined'\n ]\n\n var type = Object.prototype.toString.call(arg),\...
[ "0.6908362", "0.6774889", "0.6606997", "0.65384954", "0.64926404", "0.6489072", "0.6489072", "0.6449892", "0.6449892", "0.6428727", "0.64280385", "0.6402795", "0.6402795", "0.63939744", "0.63939744", "0.63939744", "0.63939744", "0.63939744", "0.63939744", "0.63939744", "0.639...
0.0
-1
This handles more types than `getPropType`. Only used for error messages. See `createPrimitiveTypeChecker`.
function getPreciseType(propValue) { if (typeof propValue === 'undefined' || propValue === null) { return '' + propValue; } var propType = getPropType(propValue); if (propType === 'object') { if (propValue instanceof Date) { return 'date'; } else if (propValue instanceof RegExp) { return 'regexp'; } } return propType; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getPropType(propValue) {\n\t\t var propType = typeof propValue;\n\t\t if (Array.isArray(propValue)) {\n\t\t return 'array';\n\t\t }\n\t\t if (propValue instanceof RegExp) {\n\t\t // Old webkits (at least until Android 4.0) return 'function' rather than\n\t\t // 'object' for type...
[ "0.68783313", "0.6854933", "0.6854933", "0.6854933", "0.6854933", "0.6853718", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", "0.6848216", ...
0.0
-1
Returns a string that is postfixed to a warning about an invalid type. For example, "undefined" or "of type array"
function getPostfixForTypeWarning(value) { var type = getPreciseType(value); switch (type) { case 'array': case 'object': return 'an ' + type; case 'boolean': case 'date': case 'regexp': return 'a ' + type; default: return type; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _undefinedCoerce() {\n return '';\n}", "function getPostfixForTypeWarning(value) {\n var type = getPreciseType(value);\n switch (type) {\n case \"array\":\n case \"object\":\n return \"an \" + type;\n case \"boolean\":\n ...
[ "0.6602747", "0.65663886", "0.6560637", "0.6560637", "0.6560637", "0.6560637", "0.65234375", "0.652277", "0.6507024", "0.6507024", "0.6507024", "0.6507024", "0.6507024", "0.65024", "0.6490893", "0.64789003", "0.64789003", "0.64789003", "0.64789003", "0.64789003", "0.64789003"...
0.0
-1
Returns class name of the object, if any.
function getClassName(propValue) { if (!propValue.constructor || !propValue.constructor.name) { return ANONYMOUS; } return propValue.constructor.name; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getClassName(obj) {\n var funcNameRegex = /function\\s+(.+?)\\s*\\(/;\n var results = funcNameRegex.exec(obj['constructor'].toString());\n return (results && results.length > 1) ? results[1] : '';\n }", "getClassName() {\n return this.constructor\n .className;\n...
[ "0.7730571", "0.74697196", "0.74697196", "0.74258965", "0.7164231", "0.71448183", "0.7083163", "0.7080694", "0.6995368", "0.6971116", "0.6901662", "0.6883398", "0.67147285", "0.66557264", "0.6639163", "0.6611592", "0.6611592", "0.6611592", "0.6611592", "0.6600893", "0.6599787...
0.0
-1
Returns an operation AST given a document AST and optionally an operation name. If a name is not provided, an operation is only returned if only one is provided in the document.
function getOperationAST(documentAST, operationName) { var operation = null; for (var i = 0; i < documentAST.definitions.length; i++) { var definition = documentAST.definitions[i]; if (definition.kind === _kinds.OPERATION_DEFINITION) { if (!operationName) { // If no operation name was provided, only return an Operation if there // is one defined in the document. Upon encountering the second, return // null. if (operation) { return null; } operation = definition; } else if (definition.name && definition.name.value === operationName) { return definition; } } } return operation; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getOperationAST(documentAST, operationName) {\n var operation = null;\n\n for (var i = 0; i < documentAST.definitions.length; i++) {\n var definition = documentAST.definitions[i];\n\n if (definition.kind === _language_kinds__WEBPACK_IMPORTED_MODULE_0__[\"Kind\"].OPERATION_DEFINITION) {\n if (...
[ "0.8256176", "0.82004493", "0.82004493", "0.81809", "0.81809", "0.81494194", "0.81430614", "0.59448606", "0.59448606", "0.5887792", "0.58035177", "0.5791091", "0.57523274", "0.57154346", "0.5593686", "0.5580738", "0.55647475", "0.55647475", "0.55647475", "0.55647475", "0.5555...
0.82664794
1
Build a GraphQLSchema for use by client tools. Given the result of a client running the introspection query, creates and returns a GraphQLSchema instance which can be then used with all graphqljs tools, but cannot be used to execute a query, as introspection does not represent the "resolver", "parse" or "serialize" functions or any other serverinternal mechanisms.
function buildClientSchema(introspection) { // Get the schema from the introspection result. var schemaIntrospection = introspection.__schema; // Converts the list of types into a keyMap based on the type names. var typeIntrospectionMap = (0, _keyMap2.default)(schemaIntrospection.types, function (type) { return type.name; }); // A cache to use to store the actual GraphQLType definition objects by name. // Initialize to the GraphQL built in scalars. All functions below are inline // so that this type def cache is within the scope of the closure. var typeDefCache = { String: _scalars.GraphQLString, Int: _scalars.GraphQLInt, Float: _scalars.GraphQLFloat, Boolean: _scalars.GraphQLBoolean, ID: _scalars.GraphQLID, __Schema: _introspection.__Schema, __Directive: _introspection.__Directive, __DirectiveLocation: _introspection.__DirectiveLocation, __Type: _introspection.__Type, __Field: _introspection.__Field, __InputValue: _introspection.__InputValue, __EnumValue: _introspection.__EnumValue, __TypeKind: _introspection.__TypeKind }; // Given a type reference in introspection, return the GraphQLType instance. // preferring cached instances before building new instances. function getType(typeRef) { if (typeRef.kind === _introspection.TypeKind.LIST) { var itemRef = typeRef.ofType; if (!itemRef) { throw new Error('Decorated type deeper than introspection query.'); } return new _definition.GraphQLList(getType(itemRef)); } if (typeRef.kind === _introspection.TypeKind.NON_NULL) { var nullableRef = typeRef.ofType; if (!nullableRef) { throw new Error('Decorated type deeper than introspection query.'); } var nullableType = getType(nullableRef); !!(nullableType instanceof _definition.GraphQLNonNull) ? (0, _invariant2.default)(0, 'No nesting nonnull.') : void 0; return new _definition.GraphQLNonNull(nullableType); } return getNamedType(typeRef.name); } function getNamedType(typeName) { if (typeDefCache[typeName]) { return typeDefCache[typeName]; } var typeIntrospection = typeIntrospectionMap[typeName]; if (!typeIntrospection) { throw new Error('Invalid or incomplete schema, unknown type: ' + typeName + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.'); } var typeDef = buildType(typeIntrospection); typeDefCache[typeName] = typeDef; return typeDef; } function getInputType(typeRef) { var type = getType(typeRef); !(0, _definition.isInputType)(type) ? (0, _invariant2.default)(0, 'Introspection must provide input type for arguments.') : void 0; return type; } function getOutputType(typeRef) { var type = getType(typeRef); !(0, _definition.isOutputType)(type) ? (0, _invariant2.default)(0, 'Introspection must provide output type for fields.') : void 0; return type; } function getObjectType(typeRef) { var type = getType(typeRef); !(type instanceof _definition.GraphQLObjectType) ? (0, _invariant2.default)(0, 'Introspection must provide object type for possibleTypes.') : void 0; return type; } function getInterfaceType(typeRef) { var type = getType(typeRef); !(type instanceof _definition.GraphQLInterfaceType) ? (0, _invariant2.default)(0, 'Introspection must provide interface type for interfaces.') : void 0; return type; } // Given a type's introspection result, construct the correct // GraphQLType instance. function buildType(type) { switch (type.kind) { case _introspection.TypeKind.SCALAR: return buildScalarDef(type); case _introspection.TypeKind.OBJECT: return buildObjectDef(type); case _introspection.TypeKind.INTERFACE: return buildInterfaceDef(type); case _introspection.TypeKind.UNION: return buildUnionDef(type); case _introspection.TypeKind.ENUM: return buildEnumDef(type); case _introspection.TypeKind.INPUT_OBJECT: return buildInputObjectDef(type); default: throw new Error('Invalid or incomplete schema, unknown kind: ' + type.kind + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.'); } } function buildScalarDef(scalarIntrospection) { return new _definition.GraphQLScalarType({ name: scalarIntrospection.name, description: scalarIntrospection.description, serialize: function serialize(id) { return id; }, // Note: validation calls the parse functions to determine if a // literal value is correct. Returning null would cause use of custom // scalars to always fail validation. Returning false causes them to // always pass validation. parseValue: function parseValue() { return false; }, parseLiteral: function parseLiteral() { return false; } }); } function buildObjectDef(objectIntrospection) { return new _definition.GraphQLObjectType({ name: objectIntrospection.name, description: objectIntrospection.description, interfaces: objectIntrospection.interfaces.map(getInterfaceType), fields: function fields() { return buildFieldDefMap(objectIntrospection); } }); } function buildInterfaceDef(interfaceIntrospection) { return new _definition.GraphQLInterfaceType({ name: interfaceIntrospection.name, description: interfaceIntrospection.description, fields: function fields() { return buildFieldDefMap(interfaceIntrospection); }, resolveType: cannotExecuteClientSchema }); } function buildUnionDef(unionIntrospection) { return new _definition.GraphQLUnionType({ name: unionIntrospection.name, description: unionIntrospection.description, types: unionIntrospection.possibleTypes.map(getObjectType), resolveType: cannotExecuteClientSchema }); } function buildEnumDef(enumIntrospection) { return new _definition.GraphQLEnumType({ name: enumIntrospection.name, description: enumIntrospection.description, values: (0, _keyValMap2.default)(enumIntrospection.enumValues, function (valueIntrospection) { return valueIntrospection.name; }, function (valueIntrospection) { return { description: valueIntrospection.description, deprecationReason: valueIntrospection.deprecationReason }; }) }); } function buildInputObjectDef(inputObjectIntrospection) { return new _definition.GraphQLInputObjectType({ name: inputObjectIntrospection.name, description: inputObjectIntrospection.description, fields: function fields() { return buildInputValueDefMap(inputObjectIntrospection.inputFields); } }); } function buildFieldDefMap(typeIntrospection) { return (0, _keyValMap2.default)(typeIntrospection.fields, function (fieldIntrospection) { return fieldIntrospection.name; }, function (fieldIntrospection) { return { description: fieldIntrospection.description, deprecationReason: fieldIntrospection.deprecationReason, type: getOutputType(fieldIntrospection.type), args: buildInputValueDefMap(fieldIntrospection.args) }; }); } function buildInputValueDefMap(inputValueIntrospections) { return (0, _keyValMap2.default)(inputValueIntrospections, function (inputValue) { return inputValue.name; }, buildInputValue); } function buildInputValue(inputValueIntrospection) { var type = getInputType(inputValueIntrospection.type); var defaultValue = inputValueIntrospection.defaultValue ? (0, _valueFromAST.valueFromAST)((0, _parser.parseValue)(inputValueIntrospection.defaultValue), type) : undefined; return { name: inputValueIntrospection.name, description: inputValueIntrospection.description, type: type, defaultValue: defaultValue }; } function buildDirective(directiveIntrospection) { // Support deprecated `on****` fields for building `locations`, as this // is used by GraphiQL which may need to support outdated servers. var locations = directiveIntrospection.locations ? directiveIntrospection.locations.slice() : [].concat(!directiveIntrospection.onField ? [] : [_directives.DirectiveLocation.FIELD], !directiveIntrospection.onOperation ? [] : [_directives.DirectiveLocation.QUERY, _directives.DirectiveLocation.MUTATION, _directives.DirectiveLocation.SUBSCRIPTION], !directiveIntrospection.onFragment ? [] : [_directives.DirectiveLocation.FRAGMENT_DEFINITION, _directives.DirectiveLocation.FRAGMENT_SPREAD, _directives.DirectiveLocation.INLINE_FRAGMENT]); return new _directives.GraphQLDirective({ name: directiveIntrospection.name, description: directiveIntrospection.description, locations: locations, args: buildInputValueDefMap(directiveIntrospection.args) }); } // Iterate through all types, getting the type definition for each, ensuring // that any type not directly referenced by a field will get created. var types = schemaIntrospection.types.map(function (typeIntrospection) { return getNamedType(typeIntrospection.name); }); // Get the root Query, Mutation, and Subscription types. var queryType = getObjectType(schemaIntrospection.queryType); var mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null; var subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null; // Get the directives supported by Introspection, assuming empty-set if // directives were not queried for. var directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : []; // Then produce and return a Schema with these types. return new _schema.GraphQLSchema({ query: queryType, mutation: mutationType, subscription: subscriptionType, types: types, directives: directives }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buildClientSchema(introspection, options) {\n (0, _isObjectLike.default)(introspection) && (0, _isObjectLike.default)(introspection.__schema) || (0, _devAssert.default)(0, \"Invalid or incomplete introspection result. Ensure that you are passing \\\"data\\\" property of introspection response and no \\\"...
[ "0.82505995", "0.82505995", "0.8033248", "0.7840775", "0.7837499", "0.76068807", "0.59443253", "0.5938706", "0.5829458", "0.5774952", "0.5774952", "0.57515067", "0.5689788", "0.5689788", "0.5682051", "0.5654787", "0.5626406", "0.5624843", "0.55889815", "0.5580657", "0.5579386...
0.7681812
6
Given a type reference in introspection, return the GraphQLType instance. preferring cached instances before building new instances.
function getType(typeRef) { if (typeRef.kind === _introspection.TypeKind.LIST) { var itemRef = typeRef.ofType; if (!itemRef) { throw new Error('Decorated type deeper than introspection query.'); } return new _definition.GraphQLList(getType(itemRef)); } if (typeRef.kind === _introspection.TypeKind.NON_NULL) { var nullableRef = typeRef.ofType; if (!nullableRef) { throw new Error('Decorated type deeper than introspection query.'); } var nullableType = getType(nullableRef); !!(nullableType instanceof _definition.GraphQLNonNull) ? (0, _invariant2.default)(0, 'No nesting nonnull.') : void 0; return new _definition.GraphQLNonNull(nullableType); } return getNamedType(typeRef.name); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getType(typeRef) {\n if (typeRef.kind === _type_introspection__WEBPACK_IMPORTED_MODULE_9__[\"TypeKind\"].LIST) {\n var itemRef = typeRef.ofType;\n\n if (!itemRef) {\n throw new Error('Decorated type deeper than introspection query.');\n }\n\n return Object(_type_definition__W...
[ "0.70358276", "0.7013947", "0.69258046", "0.69258046", "0.68886447", "0.6867862", "0.67595404", "0.6673546", "0.6604107", "0.6113917", "0.5910424", "0.5829246", "0.57148397", "0.57035923", "0.57035923", "0.5658312", "0.5619772", "0.5528878", "0.5528878", "0.5487877", "0.54791...
0.677848
7
Given a type's introspection result, construct the correct GraphQLType instance.
function buildType(type) { switch (type.kind) { case _introspection.TypeKind.SCALAR: return buildScalarDef(type); case _introspection.TypeKind.OBJECT: return buildObjectDef(type); case _introspection.TypeKind.INTERFACE: return buildInterfaceDef(type); case _introspection.TypeKind.UNION: return buildUnionDef(type); case _introspection.TypeKind.ENUM: return buildEnumDef(type); case _introspection.TypeKind.INPUT_OBJECT: return buildInputObjectDef(type); default: throw new Error('Invalid or incomplete schema, unknown kind: ' + type.kind + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.'); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buildType(type) {\n switch (type.kind) {\n case _typeIntrospection.TypeKind.SCALAR:\n return buildScalarDef(type);\n case _typeIntrospection.TypeKind.OBJECT:\n return buildObjectDef(type);\n case _typeIntrospection.TypeKind.INTERFACE:\n return buildInterfaceDef(type)...
[ "0.62939745", "0.61280996", "0.6125423", "0.60745406", "0.59689707", "0.59103006", "0.58754486", "0.58754486", "0.5817086", "0.57816267", "0.57815415", "0.57815415", "0.5747277", "0.5745704", "0.5744993", "0.5744993", "0.5703063", "0.56787306", "0.56731856", "0.56731856", "0....
0.63095886
1
Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function cannotExecuteClientSchema() { throw new Error('Client Schema cannot use Interface or Union types for execution.'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "componentDidMount() {\n // if this is the first time the home screen is loading\n // we must initialize Facebook\n if (!window.FB) {\n window.fbAsyncInit = function() {\n window.FB.init({\n appId : '280945375708713',\n cookie : true, // enable cookies to allow the s...
[ "0.5974469", "0.57186145", "0.5716361", "0.5612574", "0.56004953", "0.55447197", "0.54876053", "0.54517573", "0.5409206", "0.5384836", "0.5377717", "0.53758943", "0.5368928", "0.53428334", "0.53198874", "0.53054833", "0.5304589", "0.5263201", "0.52544636", "0.52544636", "0.51...
0.0
-1
Render a helpful description of the location of the error in the GraphQL Source document.
function highlightSourceAtLocation(source, location) { var line = location.line; var lineOffset = source.locationOffset.line - 1; var columnOffset = getColumnOffset(source, location); var contextLine = line + lineOffset; var prevLineNum = (contextLine - 1).toString(); var lineNum = contextLine.toString(); var nextLineNum = (contextLine + 1).toString(); var padLen = nextLineNum.length; var lines = source.body.split(/\r\n|[\n\r]/g); lines[0] = whitespace(source.locationOffset.column - 1) + lines[0]; return (line >= 2 ? lpad(padLen, prevLineNum) + ': ' + lines[line - 2] + '\n' : '') + lpad(padLen, lineNum) + ': ' + lines[line - 1] + '\n' + whitespace(2 + padLen + location.column - 1 + columnOffset) + '^\n' + (line < lines.length ? lpad(padLen, nextLineNum) + ': ' + lines[line] + '\n' : ''); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function displayError() {\r\n let html = `${addBookmark()}<div id=\"error-message\">${store.error}</div>`;\r\n return html;\r\n}", "customFormatErrorFn(err){\n // original error will be set by express graphql when it detects an error i.e\n // thrown in the code (either by you or any 3rd party pac...
[ "0.5840918", "0.57837224", "0.5782172", "0.5707352", "0.56868726", "0.5657486", "0.5648254", "0.5631857", "0.5541341", "0.55393326", "0.5534274", "0.5482769", "0.54566", "0.54566", "0.5434948", "0.54090387", "0.54090387", "0.54090387", "0.54090387", "0.5400498", "0.5400498", ...
0.0
-1
Prepares an object map of argument values given a list of argument definitions and list of argument AST nodes. Note: The returned value is a plain Object with a prototype, since it is exposed to user code. Care should be taken to not pull values from the Object prototype.
function getArgumentValues(def, node, variableValues) { var coercedValues = {}; var argDefs = def.args; var argNodes = node.arguments; if (!argDefs || !argNodes) { return coercedValues; } var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) { return arg.name.value; }); for (var i = 0; i < argDefs.length; i++) { var argDef = argDefs[i]; var name = argDef.name; var argType = argDef.type; var argumentNode = argNodeMap[name]; var defaultValue = argDef.defaultValue; if (!argumentNode) { if (!(0, _isInvalid2.default)(defaultValue)) { coercedValues[name] = defaultValue; } else if (argType instanceof _definition.GraphQLNonNull) { throw new _error.GraphQLError('Argument "' + name + '" of required type ' + ('"' + String(argType) + '" was not provided.'), [node]); } } else if (argumentNode.value.kind === Kind.VARIABLE) { var variableName = argumentNode.value.name.value; if (variableValues && Object.prototype.hasOwnProperty.call(variableValues, variableName) && !(0, _isInvalid2.default)(variableValues[variableName])) { // Note: this does not check that this variable value is correct. // This assumes that this query has been validated and the variable // usage here is of the correct type. coercedValues[name] = variableValues[variableName]; } else if (!(0, _isInvalid2.default)(defaultValue)) { coercedValues[name] = defaultValue; } else if (argType instanceof _definition.GraphQLNonNull) { throw new _error.GraphQLError('Argument "' + name + '" of required type "' + String(argType) + '" was ' + ('provided the variable "$' + variableName + '" which was not provided ') + 'a runtime value.', [argumentNode.value]); } } else { var valueNode = argumentNode.value; var coercedValue = (0, _valueFromAST.valueFromAST)(valueNode, argType, variableValues); if ((0, _isInvalid2.default)(coercedValue)) { var errors = (0, _isValidLiteralValue.isValidLiteralValue)(argType, valueNode); var message = errors ? '\n' + errors.join('\n') : ''; throw new _error.GraphQLError('Argument "' + name + '" got invalid value ' + (0, _printer.print)(valueNode) + '.' + message, [argumentNode.value]); } coercedValues[name] = coercedValue; } } return coercedValues; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function prepArgumentsObject(args,defaultArgs){\r\n var argList = [].slice.call(args);\r\n var outArgs = {};\r\n // print('Default args:',defaultArgs);\r\n //See if first argument is an ee object instead of a vanilla js object\r\n var firstArgumentIsEEObj = false;\r\n var argsAreObject = false;\r\n try{\r\n...
[ "0.6298875", "0.6100806", "0.6043771", "0.5722913", "0.5680329", "0.5554408", "0.55453277", "0.54476476", "0.53527766", "0.53527766", "0.5345561", "0.5345561", "0.5345561", "0.5345561", "0.5345561", "0.52523476", "0.5188495", "0.5134104", "0.5128351", "0.51180524", "0.5082037...
0.5232808
16
Prepares an object map of argument values given a directive definition and a AST node which may contain directives. Optionally also accepts a map of variable values. If the directive does not exist on the node, returns undefined. Note: The returned value is a plain Object with a prototype, since it is exposed to user code. Care should be taken to not pull values from the Object prototype.
function getDirectiveValues(directiveDef, node, variableValues) { var directiveNode = node.directives && (0, _find2.default)(node.directives, function (directive) { return directive.name.value === directiveDef.name; }); if (directiveNode) { return getArgumentValues(directiveDef, directiveNode, variableValues); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getArgumentValues(argDefs, argASTs, variableValues) {\n if (!argDefs || !argASTs) {\n return {};\n }\n var argASTMap = (0, _jsutilsKeyMap2['default'])(argASTs, function (arg) {\n return arg.name.value;\n });\n return argDefs.reduce(function (result, argDef) {\n var name = argDef.name;\n v...
[ "0.5871742", "0.57582045", "0.57582045", "0.57155085", "0.5690991", "0.5690991", "0.5671548", "0.5545311", "0.5545311", "0.55243903", "0.5481759", "0.5222148", "0.5222148", "0.5170159", "0.51521903", "0.51521903", "0.49799544", "0.48289886", "0.48289886", "0.46902588", "0.468...
0.57359236
4
Given a type and any value, return a runtime value coerced to match the type.
function coerceValue(type, value) { // Ensure flow knows that we treat function params as const. var _value = value; if ((0, _isInvalid2.default)(_value)) { return; // Intentionally return no value. } if (type instanceof _definition.GraphQLNonNull) { if (_value === null) { return; // Intentionally return no value. } return coerceValue(type.ofType, _value); } if (_value === null) { // Intentionally return the value null. return null; } if (type instanceof _definition.GraphQLList) { var itemType = type.ofType; if ((0, _iterall.isCollection)(_value)) { var coercedValues = []; var valueIter = (0, _iterall.createIterator)(_value); if (!valueIter) { return; // Intentionally return no value. } var step = void 0; while (!(step = valueIter.next()).done) { var itemValue = coerceValue(itemType, step.value); if ((0, _isInvalid2.default)(itemValue)) { return; // Intentionally return no value. } coercedValues.push(itemValue); } return coercedValues; } var coercedValue = coerceValue(itemType, _value); if ((0, _isInvalid2.default)(coercedValue)) { return; // Intentionally return no value. } return [coerceValue(itemType, _value)]; } if (type instanceof _definition.GraphQLInputObjectType) { if ((typeof _value === 'undefined' ? 'undefined' : _typeof(_value)) !== 'object') { return; // Intentionally return no value. } var coercedObj = Object.create(null); var fields = type.getFields(); var fieldNames = Object.keys(fields); for (var i = 0; i < fieldNames.length; i++) { var fieldName = fieldNames[i]; var field = fields[fieldName]; if ((0, _isInvalid2.default)(_value[fieldName])) { if (!(0, _isInvalid2.default)(field.defaultValue)) { coercedObj[fieldName] = field.defaultValue; } else if (field.type instanceof _definition.GraphQLNonNull) { return; // Intentionally return no value. } continue; } var fieldValue = coerceValue(field.type, _value[fieldName]); if ((0, _isInvalid2.default)(fieldValue)) { return; // Intentionally return no value. } coercedObj[fieldName] = fieldValue; } return coercedObj; } !(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType) ? (0, _invariant2.default)(0, 'Must be input type') : void 0; var parsed = type.parseValue(_value); if ((0, _isNullish2.default)(parsed)) { // null or invalid values represent a failure to parse correctly, // in which case no value is returned. return; } return parsed; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function coerceType(type, value) {\n var converter = TYPE_CONVERTERS[type];\n\n if (converter) {\n return converter(value);\n } else {\n return value;\n }\n }", "function coerceType(type, value) {\n var converter = TYPE_CONVERTERS[type];\n if (converter) {\n return converter(v...
[ "0.696873", "0.6936545", "0.68355554", "0.68039614", "0.64534086", "0.62174875", "0.61955523", "0.6058087", "0.60322535", "0.60171837", "0.5994121", "0.5948722", "0.5948505", "0.5936745", "0.5864717", "0.57184243", "0.5698542", "0.5684638", "0.5684638", "0.5684638", "0.568463...
0.5725157
16
Produces a new schema given an existing schema and a document which may contain GraphQL type extensions and definitions. The original schema will remain unaltered. Because a schema represents a graph of references, a schema cannot be extended without effectively making an entire copy. We do not know until it's too late if subgraphs remain unchanged. This algorithm copies the provided schema, applying extensions while producing the copy. The original schema remains unaltered. Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function extendSchema(schema, documentAST) { !(schema instanceof _schema.GraphQLSchema) ? (0, _invariant2.default)(0, 'Must provide valid GraphQLSchema') : void 0; !(documentAST && documentAST.kind === Kind.DOCUMENT) ? (0, _invariant2.default)(0, 'Must provide valid Document AST') : void 0; // Collect the type definitions and extensions found in the document. var typeDefinitionMap = Object.create(null); var typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can // have the same name. For example, a type named "skip". var directiveDefinitions = []; for (var i = 0; i < documentAST.definitions.length; i++) { var def = documentAST.definitions[i]; switch (def.kind) { case Kind.OBJECT_TYPE_DEFINITION: case Kind.INTERFACE_TYPE_DEFINITION: case Kind.ENUM_TYPE_DEFINITION: case Kind.UNION_TYPE_DEFINITION: case Kind.SCALAR_TYPE_DEFINITION: case Kind.INPUT_OBJECT_TYPE_DEFINITION: // Sanity check that none of the defined types conflict with the // schema's existing types. var typeName = def.name.value; if (schema.getType(typeName)) { throw new _GraphQLError.GraphQLError('Type "' + typeName + '" already exists in the schema. It cannot also ' + 'be defined in this type definition.', [def]); } typeDefinitionMap[typeName] = def; break; case Kind.TYPE_EXTENSION_DEFINITION: // Sanity check that this type extension exists within the // schema's existing types. var extendedTypeName = def.definition.name.value; var existingType = schema.getType(extendedTypeName); if (!existingType) { throw new _GraphQLError.GraphQLError('Cannot extend type "' + extendedTypeName + '" because it does not ' + 'exist in the existing schema.', [def.definition]); } if (!(existingType instanceof _definition.GraphQLObjectType)) { throw new _GraphQLError.GraphQLError('Cannot extend non-object type "' + extendedTypeName + '".', [def.definition]); } var extensions = typeExtensionsMap[extendedTypeName]; if (extensions) { extensions.push(def); } else { extensions = [def]; } typeExtensionsMap[extendedTypeName] = extensions; break; case Kind.DIRECTIVE_DEFINITION: var directiveName = def.name.value; var existingDirective = schema.getDirective(directiveName); if (existingDirective) { throw new _GraphQLError.GraphQLError('Directive "' + directiveName + '" already exists in the schema. It ' + 'cannot be redefined.', [def]); } directiveDefinitions.push(def); break; } } // If this document contains no new types, extensions, or directives then // return the same unmodified GraphQLSchema instance. if (Object.keys(typeExtensionsMap).length === 0 && Object.keys(typeDefinitionMap).length === 0 && directiveDefinitions.length === 0) { return schema; } // A cache to use to store the actual GraphQLType definition objects by name. // Initialize to the GraphQL built in scalars and introspection types. All // functions below are inline so that this type def cache is within the scope // of the closure. var typeDefCache = { String: _scalars.GraphQLString, Int: _scalars.GraphQLInt, Float: _scalars.GraphQLFloat, Boolean: _scalars.GraphQLBoolean, ID: _scalars.GraphQLID, __Schema: _introspection.__Schema, __Directive: _introspection.__Directive, __DirectiveLocation: _introspection.__DirectiveLocation, __Type: _introspection.__Type, __Field: _introspection.__Field, __InputValue: _introspection.__InputValue, __EnumValue: _introspection.__EnumValue, __TypeKind: _introspection.__TypeKind }; // Get the root Query, Mutation, and Subscription object types. var queryType = getTypeFromDef(schema.getQueryType()); var existingMutationType = schema.getMutationType(); var mutationType = existingMutationType ? getTypeFromDef(existingMutationType) : null; var existingSubscriptionType = schema.getSubscriptionType(); var subscriptionType = existingSubscriptionType ? getTypeFromDef(existingSubscriptionType) : null; // Iterate through all types, getting the type definition for each, ensuring // that any type not directly referenced by a field will get created. var typeMap = schema.getTypeMap(); var types = Object.keys(typeMap).map(function (typeName) { return getTypeFromDef(typeMap[typeName]); }); // Do the same with new types, appending to the list of defined types. Object.keys(typeDefinitionMap).forEach(function (typeName) { types.push(getTypeFromAST(typeDefinitionMap[typeName])); }); // Then produce and return a Schema with these types. return new _schema.GraphQLSchema({ query: queryType, mutation: mutationType, subscription: subscriptionType, types: types, directives: getMergedDirectives(), astNode: schema.astNode }); // Below are functions used for producing this schema that have closed over // this scope and have access to the schema, cache, and newly defined types. function getMergedDirectives() { var existingDirectives = schema.getDirectives(); !existingDirectives ? (0, _invariant2.default)(0, 'schema must have default directives') : void 0; var newDirectives = directiveDefinitions.map(function (directiveNode) { return getDirective(directiveNode); }); return existingDirectives.concat(newDirectives); } function getTypeFromDef(typeDef) { var type = _getNamedType(typeDef.name); !type ? (0, _invariant2.default)(0, 'Missing type from schema') : void 0; return type; } function getTypeFromAST(node) { var type = _getNamedType(node.name.value); if (!type) { throw new _GraphQLError.GraphQLError('Unknown type: "' + node.name.value + '". Ensure that this type exists ' + 'either in the original schema, or is added in a type definition.', [node]); } return type; } function getObjectTypeFromAST(node) { var type = getTypeFromAST(node); !(type instanceof _definition.GraphQLObjectType) ? (0, _invariant2.default)(0, 'Must be Object type.') : void 0; return type; } function getInterfaceTypeFromAST(node) { var type = getTypeFromAST(node); !(type instanceof _definition.GraphQLInterfaceType) ? (0, _invariant2.default)(0, 'Must be Interface type.') : void 0; return type; } function getInputTypeFromAST(node) { return (0, _definition.assertInputType)(getTypeFromAST(node)); } function getOutputTypeFromAST(node) { return (0, _definition.assertOutputType)(getTypeFromAST(node)); } // Given a name, returns a type from either the existing schema or an // added type. function _getNamedType(typeName) { var cachedTypeDef = typeDefCache[typeName]; if (cachedTypeDef) { return cachedTypeDef; } var existingType = schema.getType(typeName); if (existingType) { var typeDef = extendType(existingType); typeDefCache[typeName] = typeDef; return typeDef; } var typeNode = typeDefinitionMap[typeName]; if (typeNode) { var _typeDef = buildType(typeNode); typeDefCache[typeName] = _typeDef; return _typeDef; } } // Given a type's introspection result, construct the correct // GraphQLType instance. function extendType(type) { if (type instanceof _definition.GraphQLObjectType) { return extendObjectType(type); } if (type instanceof _definition.GraphQLInterfaceType) { return extendInterfaceType(type); } if (type instanceof _definition.GraphQLUnionType) { return extendUnionType(type); } return type; } function extendObjectType(type) { var name = type.name; var extensionASTNodes = type.extensionASTNodes; if (typeExtensionsMap[name]) { extensionASTNodes = extensionASTNodes.concat(typeExtensionsMap[name]); } return new _definition.GraphQLObjectType({ name: name, description: type.description, interfaces: function interfaces() { return extendImplementedInterfaces(type); }, fields: function fields() { return extendFieldMap(type); }, astNode: type.astNode, extensionASTNodes: extensionASTNodes, isTypeOf: type.isTypeOf }); } function extendInterfaceType(type) { return new _definition.GraphQLInterfaceType({ name: type.name, description: type.description, fields: function fields() { return extendFieldMap(type); }, astNode: type.astNode, resolveType: type.resolveType }); } function extendUnionType(type) { return new _definition.GraphQLUnionType({ name: type.name, description: type.description, types: type.getTypes().map(getTypeFromDef), astNode: type.astNode, resolveType: type.resolveType }); } function extendImplementedInterfaces(type) { var interfaces = type.getInterfaces().map(getTypeFromDef); // If there are any extensions to the interfaces, apply those here. var extensions = typeExtensionsMap[type.name]; if (extensions) { extensions.forEach(function (extension) { extension.definition.interfaces.forEach(function (namedType) { var interfaceName = namedType.name.value; if (interfaces.some(function (def) { return def.name === interfaceName; })) { throw new _GraphQLError.GraphQLError('Type "' + type.name + '" already implements "' + interfaceName + '". ' + 'It cannot also be implemented in this type extension.', [namedType]); } interfaces.push(getInterfaceTypeFromAST(namedType)); }); }); } return interfaces; } function extendFieldMap(type) { var newFieldMap = Object.create(null); var oldFieldMap = type.getFields(); Object.keys(oldFieldMap).forEach(function (fieldName) { var field = oldFieldMap[fieldName]; newFieldMap[fieldName] = { description: field.description, deprecationReason: field.deprecationReason, type: extendFieldType(field.type), args: (0, _keyMap2.default)(field.args, function (arg) { return arg.name; }), astNode: field.astNode, resolve: field.resolve }; }); // If there are any extensions to the fields, apply those here. var extensions = typeExtensionsMap[type.name]; if (extensions) { extensions.forEach(function (extension) { extension.definition.fields.forEach(function (field) { var fieldName = field.name.value; if (oldFieldMap[fieldName]) { throw new _GraphQLError.GraphQLError('Field "' + type.name + '.' + fieldName + '" already exists in the ' + 'schema. It cannot also be defined in this type extension.', [field]); } newFieldMap[fieldName] = { description: (0, _buildASTSchema.getDescription)(field), type: buildOutputFieldType(field.type), args: buildInputValues(field.arguments), deprecationReason: (0, _buildASTSchema.getDeprecationReason)(field), astNode: field }; }); }); } return newFieldMap; } function extendFieldType(typeDef) { if (typeDef instanceof _definition.GraphQLList) { return new _definition.GraphQLList(extendFieldType(typeDef.ofType)); } if (typeDef instanceof _definition.GraphQLNonNull) { return new _definition.GraphQLNonNull(extendFieldType(typeDef.ofType)); } return getTypeFromDef(typeDef); } function buildType(typeNode) { switch (typeNode.kind) { case Kind.OBJECT_TYPE_DEFINITION: return buildObjectType(typeNode); case Kind.INTERFACE_TYPE_DEFINITION: return buildInterfaceType(typeNode); case Kind.UNION_TYPE_DEFINITION: return buildUnionType(typeNode); case Kind.SCALAR_TYPE_DEFINITION: return buildScalarType(typeNode); case Kind.ENUM_TYPE_DEFINITION: return buildEnumType(typeNode); case Kind.INPUT_OBJECT_TYPE_DEFINITION: return buildInputObjectType(typeNode); } throw new TypeError('Unknown type kind ' + typeNode.kind); } function buildObjectType(typeNode) { return new _definition.GraphQLObjectType({ name: typeNode.name.value, description: (0, _buildASTSchema.getDescription)(typeNode), interfaces: function interfaces() { return buildImplementedInterfaces(typeNode); }, fields: function fields() { return buildFieldMap(typeNode); }, astNode: typeNode }); } function buildInterfaceType(typeNode) { return new _definition.GraphQLInterfaceType({ name: typeNode.name.value, description: (0, _buildASTSchema.getDescription)(typeNode), fields: function fields() { return buildFieldMap(typeNode); }, astNode: typeNode, resolveType: cannotExecuteExtendedSchema }); } function buildUnionType(typeNode) { return new _definition.GraphQLUnionType({ name: typeNode.name.value, description: (0, _buildASTSchema.getDescription)(typeNode), types: typeNode.types.map(getObjectTypeFromAST), astNode: typeNode, resolveType: cannotExecuteExtendedSchema }); } function buildScalarType(typeNode) { return new _definition.GraphQLScalarType({ name: typeNode.name.value, description: (0, _buildASTSchema.getDescription)(typeNode), astNode: typeNode, serialize: function serialize(id) { return id; }, // Note: validation calls the parse functions to determine if a // literal value is correct. Returning null would cause use of custom // scalars to always fail validation. Returning false causes them to // always pass validation. parseValue: function parseValue() { return false; }, parseLiteral: function parseLiteral() { return false; } }); } function buildEnumType(typeNode) { return new _definition.GraphQLEnumType({ name: typeNode.name.value, description: (0, _buildASTSchema.getDescription)(typeNode), values: (0, _keyValMap2.default)(typeNode.values, function (enumValue) { return enumValue.name.value; }, function (enumValue) { return { description: (0, _buildASTSchema.getDescription)(enumValue), deprecationReason: (0, _buildASTSchema.getDeprecationReason)(enumValue), astNode: enumValue }; }), astNode: typeNode }); } function buildInputObjectType(typeNode) { return new _definition.GraphQLInputObjectType({ name: typeNode.name.value, description: (0, _buildASTSchema.getDescription)(typeNode), fields: function fields() { return buildInputValues(typeNode.fields); }, astNode: typeNode }); } function getDirective(directiveNode) { return new _directives.GraphQLDirective({ name: directiveNode.name.value, description: (0, _buildASTSchema.getDescription)(directiveNode), locations: directiveNode.locations.map(function (node) { return node.value; }), args: directiveNode.arguments && buildInputValues(directiveNode.arguments), astNode: directiveNode }); } function buildImplementedInterfaces(typeNode) { return typeNode.interfaces && typeNode.interfaces.map(getInterfaceTypeFromAST); } function buildFieldMap(typeNode) { return (0, _keyValMap2.default)(typeNode.fields, function (field) { return field.name.value; }, function (field) { return { type: buildOutputFieldType(field.type), description: (0, _buildASTSchema.getDescription)(field), args: buildInputValues(field.arguments), deprecationReason: (0, _buildASTSchema.getDeprecationReason)(field), astNode: field }; }); } function buildInputValues(values) { return (0, _keyValMap2.default)(values, function (value) { return value.name.value; }, function (value) { var type = buildInputFieldType(value.type); return { type: type, description: (0, _buildASTSchema.getDescription)(value), defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type), astNode: value }; }); } function buildInputFieldType(typeNode) { if (typeNode.kind === Kind.LIST_TYPE) { return new _definition.GraphQLList(buildInputFieldType(typeNode.type)); } if (typeNode.kind === Kind.NON_NULL_TYPE) { var nullableType = buildInputFieldType(typeNode.type); !!(nullableType instanceof _definition.GraphQLNonNull) ? (0, _invariant2.default)(0, 'Must be nullable') : void 0; return new _definition.GraphQLNonNull(nullableType); } return getInputTypeFromAST(typeNode); } function buildOutputFieldType(typeNode) { if (typeNode.kind === Kind.LIST_TYPE) { return new _definition.GraphQLList(buildOutputFieldType(typeNode.type)); } if (typeNode.kind === Kind.NON_NULL_TYPE) { var nullableType = buildOutputFieldType(typeNode.type); !!(nullableType instanceof _definition.GraphQLNonNull) ? (0, _invariant2.default)(0, 'Must be nullable') : void 0; return new _definition.GraphQLNonNull(nullableType); } return getOutputTypeFromAST(typeNode); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function extendSchema(schema, documentAST) {\n (0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Must provide valid GraphQLSchema');\n\n (0, _invariant2.default)(documentAST && documentAST.kind === _kinds.DOCUMENT, 'Must provide valid Document AST');\n\n // Collect the type definitions and exte...
[ "0.6949743", "0.693651", "0.6849844", "0.67141265", "0.66822195", "0.66752064", "0.66744983", "0.66744983", "0.63838375", "0.6246834", "0.6108762", "0.57664764", "0.56211686", "0.56211686", "0.55488354", "0.5544573", "0.5544573", "0.5388623", "0.53882587", "0.53617626", "0.53...
0.693651
2
Below are functions used for producing this schema that have closed over this scope and have access to the schema, cache, and newly defined types.
function getMergedDirectives() { var existingDirectives = schema.getDirectives(); !existingDirectives ? (0, _invariant2.default)(0, 'schema must have default directives') : void 0; var newDirectives = directiveDefinitions.map(function (directiveNode) { return getDirective(directiveNode); }); return existingDirectives.concat(newDirectives); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "generateSchema() {\n var that = this;\n\n _.keys(this).forEach(function(k) {\n // Ignore private variables\n if (_.startsWith(k, '_')) {\n return;\n }\n\n // Normalize the type format\n that._schema[k] = normalizeType(that[k]);\n\n...
[ "0.683943", "0.67439026", "0.6719679", "0.6636293", "0.61818635", "0.60078526", "0.5942807", "0.58237904", "0.58194065", "0.5807469", "0.58035827", "0.57826406", "0.5692334", "0.5655116", "0.5655116", "0.5652961", "0.56424016", "0.56018525", "0.5601527", "0.55834466", "0.5583...
0.0
-1
Given a name, returns a type from either the existing schema or an added type.
function _getNamedType(typeName) { var cachedTypeDef = typeDefCache[typeName]; if (cachedTypeDef) { return cachedTypeDef; } var existingType = schema.getType(typeName); if (existingType) { var typeDef = extendType(existingType); typeDefCache[typeName] = typeDef; return typeDef; } var typeNode = typeDefinitionMap[typeName]; if (typeNode) { var _typeDef = buildType(typeNode); typeDefCache[typeName] = _typeDef; return _typeDef; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getType(name){\n return types.filter(function(type_row){\n return type_row.name == name\n })[0].type;\n }", "function typeFromASTImpl(schema, typeNode) {\n /* eslint-enable no-redeclare */\n var innerType = void 0;\n if (typeNode.kind === _kinds.LIST_TYPE) {\n innerType...
[ "0.66821307", "0.6298792", "0.6220048", "0.6173743", "0.6113745", "0.6113745", "0.61046654", "0.60410345", "0.60016274", "0.58115554", "0.58029455", "0.5760719", "0.5736607", "0.5675311", "0.5655244", "0.5628826", "0.5599253", "0.554934", "0.55090624", "0.5464568", "0.5458455...
0.61292815
5
Given a type's introspection result, construct the correct GraphQLType instance.
function extendType(type) { if (type instanceof _definition.GraphQLObjectType) { return extendObjectType(type); } if (type instanceof _definition.GraphQLInterfaceType) { return extendInterfaceType(type); } if (type instanceof _definition.GraphQLUnionType) { return extendUnionType(type); } return type; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function buildType(type) {\n switch (type.kind) {\n case _introspection.TypeKind.SCALAR:\n return buildScalarDef(type);\n case _introspection.TypeKind.OBJECT:\n return buildObjectDef(type);\n case _introspection.TypeKind.INTERFACE:\n return buildInterfaceDef(type);\n cas...
[ "0.63089025", "0.63089025", "0.6293208", "0.6127647", "0.6124885", "0.6076708", "0.5971129", "0.5909885", "0.5877163", "0.5877163", "0.581831", "0.5782846", "0.5782839", "0.5782839", "0.57477754", "0.5747592", "0.57451797", "0.57451797", "0.57043284", "0.5679536", "0.56735647...
0.5302451
41
Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function printSchema(schema) { return printFilteredSchema(schema, function (n) { return !isSpecDirective(n); }, isDefinedType); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "componentDidMount() {\n // if this is the first time the home screen is loading\n // we must initialize Facebook\n if (!window.FB) {\n window.fbAsyncInit = function() {\n window.FB.init({\n appId : '280945375708713',\n cookie : true, // enable cookies to allow the s...
[ "0.5976053", "0.57203424", "0.57181513", "0.5614843", "0.56018084", "0.55464816", "0.54893225", "0.5453807", "0.5409828", "0.53852314", "0.5378477", "0.53759915", "0.537015", "0.53436714", "0.53220254", "0.53067243", "0.5306326", "0.5264811", "0.5253494", "0.5253494", "0.5162...
0.0
-1
Provided a collection of ASTs, presumably each from different files, concatenate the ASTs together into batched AST, useful for validating many GraphQL source files which together represent one conceptual application.
function concatAST(asts) { var batchDefinitions = []; for (var i = 0; i < asts.length; i++) { var definitions = asts[i].definitions; for (var j = 0; j < definitions.length; j++) { batchDefinitions.push(definitions[j]); } } return { kind: 'Document', definitions: batchDefinitions }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function concatAST(asts) {\n\t var batchDefinitions = [];\n\t for (var i = 0; i < asts.length; i++) {\n\t var definitions = asts[i].definitions;\n\t for (var j = 0; j < definitions.length; j++) {\n\t batchDefinitions.push(definitions[j]);\n\t }\n\t }\n\t return {\n\t kind: 'Document',\n\t d...
[ "0.6908495", "0.6170209", "0.6108926", "0.5783711", "0.5783711", "0.5568391", "0.5568391", "0.5568391", "0.54284203", "0.5300837", "0.5247986", "0.5224473", "0.5103726", "0.50698173", "0.49965164", "0.49735075", "0.4945306", "0.4937225", "0.4897356", "0.48926285", "0.48727074...
0.7075156
1
separateOperations accepts a single AST document which may contain many operations and fragments and returns a collection of AST documents each of which contains a single operation as well the fragment definitions it refers to.
function separateOperations(documentAST) { var operations = []; var fragments = Object.create(null); var positions = new Map(); var depGraph = Object.create(null); var fromName = void 0; var idx = 0; // Populate metadata and build a dependency graph. (0, _visitor.visit)(documentAST, { OperationDefinition: function OperationDefinition(node) { fromName = opName(node); operations.push(node); positions.set(node, idx++); }, FragmentDefinition: function FragmentDefinition(node) { fromName = node.name.value; fragments[fromName] = node; positions.set(node, idx++); }, FragmentSpread: function FragmentSpread(node) { var toName = node.name.value; (depGraph[fromName] || (depGraph[fromName] = Object.create(null)))[toName] = true; } }); // For each operation, produce a new synthesized AST which includes only what // is necessary for completing that operation. var separatedDocumentASTs = Object.create(null); operations.forEach(function (operation) { var operationName = opName(operation); var dependencies = Object.create(null); collectTransitiveDependencies(dependencies, depGraph, operationName); // The list of definition nodes to be included for this operation, sorted // to retain the same order as the original document. var definitions = [operation]; Object.keys(dependencies).forEach(function (name) { definitions.push(fragments[name]); }); definitions.sort(function (n1, n2) { return (positions.get(n1) || 0) - (positions.get(n2) || 0); }); separatedDocumentASTs[operationName] = { kind: 'Document', definitions: definitions }; }); return separatedDocumentASTs; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function separateOperations(documentAST) {\n var operations = [];\n var fragments = Object.create(null);\n var positions = new Map();\n var depGraph = Object.create(null);\n var fromName;\n var idx = 0; // Populate metadata and build a dependency graph.\n\n Object(_language_visitor__WEBPACK_IMPORTED_MODULE_...
[ "0.8374256", "0.8355116", "0.8355116", "0.8323192", "0.8316201", "0.82667154", "0.8087221", "0.5841627", "0.58005786", "0.58005786", "0.57366604", "0.57366604", "0.5730869", "0.5730869", "0.572303", "0.56546056", "0.5631241", "0.55107546", "0.5228565", "0.5228565", "0.5228565...
0.8288285
5
Copyright (c) 2015present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree. Provides the empty string for anonymous operations.
function opName(operation) { return operation.name ? operation.name.value : ''; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function anonOperationNotAloneMessage() {\n return 'This anonymous operation must be the only defined operation.';\n}", "function funcName(func) {\n return func.name || \"{anonymous}\"\n }", "function getAnonymousAccessToken() {\n return '18cdaa6481c0d5f323351ea1029fc065';\n}", "function opName...
[ "0.6723057", "0.60533273", "0.58629614", "0.58295256", "0.5754795", "0.5647995", "0.56423646", "0.5589107", "0.5589107", "0.55403537", "0.5523034", "0.5497931", "0.54720825", "0.54704314", "0.545724", "0.5454261", "0.5445035", "0.54419726", "0.5420199", "0.5420199", "0.542019...
0.57936543
5
From a dependency graph, collects a list of transitive dependencies by recursing through a dependency graph.
function collectTransitiveDependencies(collected, depGraph, fromName) { var immediateDeps = depGraph[fromName]; if (immediateDeps) { Object.keys(immediateDeps).forEach(function (toName) { if (!collected[toName]) { collected[toName] = true; collectTransitiveDependencies(collected, depGraph, toName); } }); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function collectTransitiveDependencies(collected, depGraph, fromName) {\n if (!collected.has(fromName)) {\n collected.add(fromName);\n var immediateDeps = depGraph[fromName];\n\n if (immediateDeps !== undefined) {\n for (var _i8 = 0; _i8 < immediateDeps.length; _i8++) {\n var toName = immedia...
[ "0.7477809", "0.7477809", "0.7364086", "0.7317418", "0.73093545", "0.73093545", "0.6294312", "0.6256443", "0.62223786", "0.61657584", "0.61096203", "0.6086029", "0.5823758", "0.57858723", "0.56729895", "0.562311", "0.5549224", "0.55204785", "0.54759014", "0.5455502", "0.54510...
0.7390656
3
Given two schemas, returns an Array containing descriptions of all the types of breaking changes covered by the other functions down below.
function findBreakingChanges(oldSchema, newSchema) { return [].concat(findRemovedTypes(oldSchema, newSchema), findTypesThatChangedKind(oldSchema, newSchema), findFieldsThatChangedType(oldSchema, newSchema), findTypesRemovedFromUnions(oldSchema, newSchema), findValuesRemovedFromEnums(oldSchema, newSchema), findArgChanges(oldSchema, newSchema).breakingChanges, findInterfacesRemovedFromObjectTypes(oldSchema, newSchema)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findBreakingChanges(oldSchema, newSchema) {\n\t return [].concat(findRemovedTypes(oldSchema, newSchema), findTypesThatChangedKind(oldSchema, newSchema), findFieldsThatChangedType(oldSchema, newSchema), findTypesRemovedFromUnions(oldSchema, newSchema), findValuesRemovedFromEnums(oldSchema, newSchema));\n\...
[ "0.76721257", "0.7485684", "0.74180543", "0.7411905", "0.74099255", "0.74099255", "0.71563596", "0.7117689", "0.7117689", "0.7061867", "0.70333153", "0.70333153", "0.70333153", "0.66911477", "0.66376525", "0.6494975", "0.6494975", "0.6386537", "0.6386537", "0.6386426", "0.622...
0.7492621
2
Given two schemas, returns an Array containing descriptions of all the types of potentially dangerous changes covered by the other functions down below.
function findDangerousChanges(oldSchema, newSchema) { return [].concat(findArgChanges(oldSchema, newSchema).dangerousChanges, findValuesAddedToEnums(oldSchema, newSchema), findTypesAddedToUnions(oldSchema, newSchema)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findDangerousChanges(oldSchema, newSchema) {\n return [].concat(findArgChanges(oldSchema, newSchema).dangerousChanges, findValuesAddedToEnums(oldSchema, newSchema), findInterfacesAddedToObjectTypes(oldSchema, newSchema), findTypesAddedToUnions(oldSchema, newSchema), findFieldsThatChangedTypeOnInputObject...
[ "0.7039056", "0.70201594", "0.6972318", "0.6959837", "0.6959837", "0.6959837", "0.6959837", "0.6901334", "0.6893894", "0.6893894", "0.68903375", "0.6874852", "0.6867015", "0.6867015", "0.68197554", "0.67576176", "0.67539984", "0.67539984", "0.65311575", "0.6468782", "0.646878...
0.7191499
0
Given two schemas, returns an Array containing descriptions of any breaking changes in the newSchema related to removing an entire type.
function findRemovedTypes(oldSchema, newSchema) { var oldTypeMap = oldSchema.getTypeMap(); var newTypeMap = newSchema.getTypeMap(); var breakingChanges = []; Object.keys(oldTypeMap).forEach(function (typeName) { if (!newTypeMap[typeName]) { breakingChanges.push({ type: BreakingChangeType.TYPE_REMOVED, description: typeName + ' was removed.' }); } }); return breakingChanges; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findRemovedTypes(oldSchema, newSchema) {\n var oldTypeMap = oldSchema.getTypeMap();\n var newTypeMap = newSchema.getTypeMap();\n var breakingChanges = [];\n\n var _arr = Object.keys(oldTypeMap);\n\n for (var _i = 0; _i < _arr.length; _i++) {\n var typeName = _arr[_i];\n\n if (!newTypeMap[typeNa...
[ "0.8176876", "0.814868", "0.7263231", "0.7255352", "0.72205025", "0.72205025", "0.7170979", "0.70155483", "0.70155483", "0.697916", "0.69538426", "0.69538426", "0.6949668", "0.6916142", "0.6904582", "0.67299575", "0.67047393", "0.67047393", "0.67047393", "0.66956633", "0.6695...
0.82110786
1
Given two schemas, returns an Array containing descriptions of any breaking changes in the newSchema related to changing the type of a type.
function findTypesThatChangedKind(oldSchema, newSchema) { var oldTypeMap = oldSchema.getTypeMap(); var newTypeMap = newSchema.getTypeMap(); var breakingChanges = []; Object.keys(oldTypeMap).forEach(function (typeName) { if (!newTypeMap[typeName]) { return; } var oldType = oldTypeMap[typeName]; var newType = newTypeMap[typeName]; if (!(oldType instanceof newType.constructor)) { breakingChanges.push({ type: BreakingChangeType.TYPE_CHANGED_KIND, description: typeName + ' changed from ' + (typeKindName(oldType) + ' to ' + typeKindName(newType) + '.') }); } }); return breakingChanges; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findTypesThatChangedKind(oldSchema, newSchema) {\n var oldTypeMap = oldSchema.getTypeMap();\n var newTypeMap = newSchema.getTypeMap();\n var breakingChanges = [];\n\n var _arr2 = Object.keys(oldTypeMap);\n\n for (var _i2 = 0; _i2 < _arr2.length; _i2++) {\n var typeName = _arr2[_i2];\n\n if (!ne...
[ "0.8103693", "0.8060752", "0.78412163", "0.7751845", "0.7751845", "0.77466553", "0.7723766", "0.7634768", "0.7634768", "0.76183236", "0.7545555", "0.7199528", "0.7199528", "0.71913576", "0.71913576", "0.71913576", "0.7042182", "0.7042182", "0.7023725", "0.69522476", "0.683800...
0.80712616
2
Given two schemas, returns an Array containing descriptions of any breaking or dangerous changes in the newSchema related to arguments (such as removal or change of type of an argument, or a change in an argument's default value).
function findArgChanges(oldSchema, newSchema) { var oldTypeMap = oldSchema.getTypeMap(); var newTypeMap = newSchema.getTypeMap(); var breakingChanges = []; var dangerousChanges = []; Object.keys(oldTypeMap).forEach(function (typeName) { var oldType = oldTypeMap[typeName]; var newType = newTypeMap[typeName]; if (!(oldType instanceof _definition.GraphQLObjectType || oldType instanceof _definition.GraphQLInterfaceType) || !(newType instanceof oldType.constructor)) { return; } var oldTypeFields = oldType.getFields(); var newTypeFields = newType.getFields(); Object.keys(oldTypeFields).forEach(function (fieldName) { if (!newTypeFields[fieldName]) { return; } oldTypeFields[fieldName].args.forEach(function (oldArgDef) { var newArgs = newTypeFields[fieldName].args; var newArgDef = newArgs.find(function (arg) { return arg.name === oldArgDef.name; }); // Arg not present if (!newArgDef) { breakingChanges.push({ type: BreakingChangeType.ARG_REMOVED, description: oldType.name + '.' + fieldName + ' arg ' + (oldArgDef.name + ' was removed') }); } else { var isSafe = isChangeSafeForInputObjectFieldOrFieldArg(oldArgDef.type, newArgDef.type); if (!isSafe) { breakingChanges.push({ type: BreakingChangeType.ARG_CHANGED_KIND, description: oldType.name + '.' + fieldName + ' arg ' + (oldArgDef.name + ' has changed type from ') + (oldArgDef.type.toString() + ' to ' + newArgDef.type.toString()) }); } else if (oldArgDef.defaultValue !== undefined && oldArgDef.defaultValue !== newArgDef.defaultValue) { dangerousChanges.push({ type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, description: oldType.name + '.' + fieldName + ' arg ' + (oldArgDef.name + ' has changed defaultValue') }); } } }); // Check if a non-null arg was added to the field newTypeFields[fieldName].args.forEach(function (newArgDef) { var oldArgs = oldTypeFields[fieldName].args; var oldArgDef = oldArgs.find(function (arg) { return arg.name === newArgDef.name; }); if (!oldArgDef && newArgDef.type instanceof _definition.GraphQLNonNull) { breakingChanges.push({ type: BreakingChangeType.NON_NULL_ARG_ADDED, description: 'A non-null arg ' + newArgDef.name + ' on ' + (newType.name + '.' + fieldName + ' was added') }); } }); }); }); return { breakingChanges: breakingChanges, dangerousChanges: dangerousChanges }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findArgChanges(oldSchema, newSchema) {\n var oldTypeMap = oldSchema.getTypeMap();\n var newTypeMap = newSchema.getTypeMap();\n var breakingChanges = [];\n var dangerousChanges = [];\n\n var _arr3 = Object.keys(oldTypeMap);\n\n for (var _i3 = 0; _i3 < _arr3.length; _i3++) {\n var typeName = _arr3[...
[ "0.7709526", "0.7294602", "0.72251356", "0.7023517", "0.69008", "0.689002", "0.689002", "0.6832358", "0.6598981", "0.65873826", "0.65873826", "0.65614253", "0.65614253", "0.6555589", "0.6555589", "0.6555589", "0.6555589", "0.6539358", "0.6526367", "0.64818496", "0.6415634", ...
0.7818474
1