Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql-tag

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-tag - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

3

index.js

@@ -26,3 +26,4 @@ var parse = require('graphql/language/parser').parse;

var literals = args[0];
var substitutions = args.shift();
args.shift();
var substitutions = args;

@@ -29,0 +30,0 @@ var result = '';

{
"name": "graphql-tag",
"version": "0.1.2",
"version": "0.1.3",
"description": "A JavaScript template literal tag that parses GraphQL queries",

@@ -26,4 +26,5 @@ "main": "index.js",

"chai": "^3.5.0",
"lodash": "^4.13.1",
"mocha": "^2.5.3"
}
}
var gqlRequire = require('./index');
var gqlDefault = require('./index').default;
import { assert } from 'chai';
import _ from 'lodash';
function stripLoc(obj) {
if (_.isArray(obj)) {
return obj.map(stripLoc);
}
if (! _.isObject(obj)) {
return obj;
}
const omitted = _.omit(obj, ['loc']);
return _.mapValues(omitted, (value) => {
return stripLoc(value);
});
}
[gqlRequire, gqlDefault].forEach((gql, i) => {

@@ -14,3 +31,81 @@ describe(`gql ${i}`, () => {

});
it('is correct for a simple query', () => {
const ast = stripLoc(gql`
{
user(id: 5) {
firstName
lastName
}
}
`);
assert.deepEqual(ast, {
"kind": "Document",
"definitions": [
{
"kind": "OperationDefinition",
"operation": "query",
"name": null,
"variableDefinitions": null,
"directives": [],
"selectionSet": {
"kind": "SelectionSet",
"selections": [
{
"kind": "Field",
"alias": null,
"name": {
"kind": "Name",
"value": "user"
},
"arguments": [
{
"kind": "Argument",
"name": {
"kind": "Name",
"value": "id"
},
"value": {
"kind": "IntValue",
"value": "5"
}
}
],
"directives": [],
"selectionSet": {
"kind": "SelectionSet",
"selections": [
{
"kind": "Field",
"alias": null,
"name": {
"kind": "Name",
"value": "firstName"
},
"arguments": [],
"directives": [],
"selectionSet": null
},
{
"kind": "Field",
"alias": null,
"name": {
"kind": "Name",
"value": "lastName"
},
"arguments": [],
"directives": [],
"selectionSet": null
}
]
}
}
]
}
}
]
})
})
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc