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

apollo-codegen

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-codegen - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

test/starwars/ExplicitTypename.graphql

34

lib/validation.js

@@ -13,2 +13,4 @@ 'use strict';

exports.NoAnonymousQueries = NoAnonymousQueries;
exports.NoExplicitTypename = NoExplicitTypename;
exports.NoTypenameAlias = NoTypenameAlias;

@@ -22,3 +24,3 @@ var _graphql = require('graphql');

function validateQueryDocument(schema, document) {
var rules = [NoAnonymousQueries].concat(_graphql.specifiedRules);
var rules = [NoAnonymousQueries, NoExplicitTypename, NoTypenameAlias].concat(_graphql.specifiedRules);

@@ -56,9 +58,2 @@ var validationErrors = (0, _graphql.validate)(schema, document, rules);

function fixNodeLocation(node) {
// FIXME: Workaround for bug in graphql-js, see https://github.com/graphql/graphql-js/pull/487
if (node.loc.start === 0) {
node.loc.start = 1;
}
}
function NoAnonymousQueries(context) {

@@ -68,3 +63,2 @@ return {

if (!node.name) {
fixNodeLocation(node);
context.reportError(new _graphql.GraphQLError('Apollo iOS does not support anonymous operations', [node]));

@@ -76,2 +70,24 @@ }

}
function NoExplicitTypename(context) {
return {
Field: function Field(node) {
var fieldName = node.name.value;
if (fieldName == "__typename") {
context.reportError(new _graphql.GraphQLError('Apollo iOS inserts __typename automatically when needed, please do not include it explicitly', [node]));
}
}
};
}
function NoTypenameAlias(context) {
return {
Field: function Field(node) {
var aliasName = node.alias && node.alias.value;
if (aliasName == "__typename") {
context.reportError(new _graphql.GraphQLError('Apollo iOS needs to be able to insert __typename when needed, please do not use it as an alias', [node]));
}
}
};
}
//# sourceMappingURL=validation.js.map
{
"name": "apollo-codegen",
"version": "0.9.0",
"version": "0.9.1",
"description": "Generate client code based on a GraphQL schema and query documents",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -25,2 +25,22 @@ import { assert } from 'chai'

});
it(`should throw an error for ExplicitTypename.graphql`, () => {
const inputPaths = [path.join(__dirname, './starwars/ExplicitTypename.graphql')];
const document = loadAndMergeQueryDocuments(inputPaths);
assert.throws(
() => validateQueryDocument(schema, document),
'Validation of GraphQL query document failed'
);
});
it(`should throw an error for TypenameAlias.graphql`, () => {
const inputPaths = [path.join(__dirname, './starwars/TypenameAlias.graphql')];
const document = loadAndMergeQueryDocuments(inputPaths);
assert.throws(
() => validateQueryDocument(schema, document),
'Validation of GraphQL query document failed'
);
});
});

Sorry, the diff of this file is not supported yet

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