Socket
Socket
Sign inDemoInstall

apollo-graphql

Package Overview
Dependencies
6
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.4 to 0.9.5

1

lib/index.d.ts
export { defaultOperationRegistrySignature, defaultUsageReportingSignature, operationRegistrySignature, operationHash, defaultUsageReportingSignature as defaultEngineReportingSignature } from "./operationId";
export * from "./schema";
export { printWithReducedWhitespace, hideStringAndNumericLiterals, hideLiterals } from "./transforms";
//# sourceMappingURL=index.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultEngineReportingSignature = exports.operationHash = exports.operationRegistrySignature = exports.defaultUsageReportingSignature = exports.defaultOperationRegistrySignature = void 0;
exports.hideLiterals = exports.hideStringAndNumericLiterals = exports.printWithReducedWhitespace = exports.defaultEngineReportingSignature = exports.operationHash = exports.operationRegistrySignature = exports.defaultUsageReportingSignature = exports.defaultOperationRegistrySignature = void 0;
var operationId_1 = require("./operationId");

@@ -22,2 +22,6 @@ Object.defineProperty(exports, "defaultOperationRegistrySignature", { enumerable: true, get: function () { return operationId_1.defaultOperationRegistrySignature; } });

__exportStar(require("./schema"), exports);
var transforms_1 = require("./transforms");
Object.defineProperty(exports, "printWithReducedWhitespace", { enumerable: true, get: function () { return transforms_1.printWithReducedWhitespace; } });
Object.defineProperty(exports, "hideStringAndNumericLiterals", { enumerable: true, get: function () { return transforms_1.hideStringAndNumericLiterals; } });
Object.defineProperty(exports, "hideLiterals", { enumerable: true, get: function () { return transforms_1.hideLiterals; } });
//# sourceMappingURL=index.js.map

10

lib/schema/buildSchemaFromSDL.js

@@ -57,2 +57,3 @@ "use strict";

const schemaExtensions = [];
const schemaDirectives = [];
for (const definition of documentAST.definitions) {

@@ -82,2 +83,3 @@ if (graphql_1.isTypeDefinitionNode(definition)) {

schemaDefinitions.push(definition);
schemaDirectives.push(...(definition.directives ? definition.directives : []));
}

@@ -138,5 +140,9 @@ else if (definition.kind === graphql_1.Kind.SCHEMA_EXTENSION) {

}
schema = new graphql_1.GraphQLSchema(Object.assign(Object.assign({}, schema.toConfig()), mapValues_1.mapValues(operationTypeMap, typeName => typeName
schema = new graphql_1.GraphQLSchema(Object.assign(Object.assign(Object.assign({}, schema.toConfig()), mapValues_1.mapValues(operationTypeMap, typeName => typeName
? schema.getType(typeName)
: undefined)));
: undefined)), { astNode: {
kind: graphql_1.Kind.SCHEMA_DEFINITION,
directives: schemaDirectives,
operationTypes: []
} }));
for (const module of modules) {

@@ -143,0 +149,0 @@ if (!module.resolvers)

{
"name": "apollo-graphql",
"version": "0.9.4",
"version": "0.9.5",
"description": "Apollo GraphQL utility library",

@@ -47,3 +47,3 @@ "main": "lib/index.js",

},
"gitHead": "18da273fd569df153c4ee9172087fe588b9d0f11"
"gitHead": "b2d14322165e7a2ea97c69c4fdab417318608049"
}
import { default as gql, disableFragmentWarnings } from "graphql-tag";
import { printWithReducedWhitespace, hideLiterals } from "../transforms";
import {
printWithReducedWhitespace,
hideLiterals,
hideStringAndNumericLiterals
} from "../transforms";

@@ -47,3 +51,9 @@ // The gql duplicate fragment warning feature really is just warnings; nothing

query Foo($b: Int, $a: Boolean) {
user(name: "hello", age: 5) {
user(
name: "hello"
age: 5
pct: 0.4
lst: ["a", "b", "c"]
obj: { a: "a", b: 1 }
) {
...Bar

@@ -56,2 +66,9 @@ ... on User {

aliased: name
withInputs(
str: "hi"
int: 2
flt: 0.3
lst: ["x", "y", "z"]
obj: { q: "r", s: 1 }
)
}

@@ -70,3 +87,4 @@ }

output:
'query Foo($b:Int,$a:Boolean){user(name:"",age:0){...Bar...on User{hello bee}tz aliased:name}}' +
'query Foo($b:Int,$a:Boolean){user(name:"",age:0,pct:0,lst:[],obj:{}){...Bar...on User{hello bee}tz aliased:name ' +
'withInputs(str:"",int:0,flt:0,lst:[],obj:{})}}' +
"fragment Bar on User{age@skip(if:$a)...Nested}fragment Nested on User{blah}"

@@ -81,1 +99,55 @@ }

});
describe("hideStringAndNumericLiterals", () => {
const cases = [
{
name: "full test",
input: gql`
query Foo($b: Int, $a: Boolean) {
user(
name: "hello"
age: 5
pct: 0.4
lst: ["a", "b", "c"]
obj: { a: "a", b: 1 }
) {
...Bar
... on User {
hello
bee
}
tz
aliased: name
withInputs(
str: "hi"
int: 2
flt: 0.3
lst: ["", "", ""]
obj: { q: "", s: 0 }
)
}
}
fragment Bar on User {
age @skip(if: $a)
...Nested
}
fragment Nested on User {
blah
}
`,
output:
'query Foo($b:Int,$a:Boolean){user(name:"",age:0,pct:0,lst:["","",""],obj:{a:"",b:0}){...Bar...on User{hello bee}tz aliased:name ' +
'withInputs(str:"",int:0,flt:0,lst:["","",""],obj:{q:"",s:0})}}' +
"fragment Bar on User{age@skip(if:$a)...Nested}fragment Nested on User{blah}"
}
];
cases.forEach(({ name, input, output }) => {
test(name, () => {
expect(
printWithReducedWhitespace(hideStringAndNumericLiterals(input))
).toEqual(output);
});
});
});

@@ -10,1 +10,6 @@ export {

export * from "./schema";
export {
printWithReducedWhitespace,
hideStringAndNumericLiterals,
hideLiterals
} from "./transforms";

@@ -354,2 +354,25 @@ import gql from "graphql-tag";

});
it(`should preserve directive usages from the schema definition node`, () => {
const schema = buildSchemaFromSDL(
gql`
directive @contact(
name: String!
url: String!
description: String
) on SCHEMA
schema
@contact(
name: "Contact"
url: "http://example.com/contact"
description: "Testing"
) {
query: Query
}
`
);
expect(schema.astNode!.directives).toHaveLength(1);
expect(schema.astNode!.directives![0].name.value).toEqual("contact");
});
});

@@ -356,0 +379,0 @@

@@ -21,3 +21,4 @@ import {

isEnumType,
GraphQLEnumValueConfig
GraphQLEnumValueConfig,
DirectiveNode
} from "graphql";

@@ -112,2 +113,3 @@ import { validateSDL } from "graphql/validation/validate";

const schemaExtensions: SchemaExtensionNode[] = [];
const schemaDirectives: DirectiveNode[] = [];

@@ -135,2 +137,5 @@ for (const definition of documentAST.definitions) {

schemaDefinitions.push(definition);
schemaDirectives.push(
...(definition.directives ? definition.directives : [])
);
} else if (definition.kind === Kind.SCHEMA_EXTENSION) {

@@ -217,3 +222,8 @@ schemaExtensions.push(definition);

: undefined
)
),
astNode: {
kind: Kind.SCHEMA_DEFINITION,
directives: schemaDirectives,
operationTypes: [] // satisfies typescript, will be ignored
}
});

@@ -220,0 +230,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc