New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grats

Package Overview
Dependencies
Maintainers
1
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grats - npm Package Compare versions

Comparing version 0.0.0-main-c81a7c59 to 0.0.0-main-c9e75904

dist/src/tests/integrationFixtures/complexDefaultInput/index.d.ts

2

dist/src/cli.js

@@ -105,3 +105,3 @@ #!/usr/bin/env node

var schemaStr = (0, printSchema_1.printGratsSDL)(sortedSchema, config);
var absOutput = (0, path_1.resolve)(process.cwd(), config.graphqlSchema);
var absOutput = (0, path_1.resolve)((0, path_1.dirname)(configFile), config.graphqlSchema);
(0, fs_1.writeFileSync)(absOutput, schemaStr);

@@ -108,0 +108,0 @@ console.error("Grats: Wrote schema to `".concat(absOutput, "`."));

@@ -92,2 +92,7 @@ "use strict";

};
Codegen.prototype.deprecated = function (obj) {
if (!obj.deprecationReason)
return null;
return F.createPropertyAssignment("deprecationReason", F.createStringLiteral(obj.deprecationReason));
};
Codegen.prototype.description = function (description) {

@@ -274,2 +279,3 @@ if (!description)

this.description(field.description),
this.deprecated(field),
F.createPropertyAssignment("name", F.createStringLiteral(field.name)),

@@ -282,2 +288,3 @@ F.createPropertyAssignment("type", this.typeReference(field.type)),

this.description(field.description),
this.deprecated(field),
F.createPropertyAssignment("name", F.createStringLiteral(field.name)),

@@ -310,2 +317,3 @@ F.createPropertyAssignment("type", this.typeReference(field.type)),

this.description(arg.description),
this.deprecated(arg),
F.createPropertyAssignment("name", F.createStringLiteral(arg.name)),

@@ -349,2 +357,3 @@ F.createPropertyAssignment("type", this.typeReference(arg.type)),

this.description(obj.description),
this.deprecated(obj),
F.createPropertyAssignment("value", F.createStringLiteral(obj.name)),

@@ -351,0 +360,0 @@ ]);

@@ -92,1 +92,2 @@ /**

export declare function operationTypeNotUnknown(): string;
export declare function expectedNullableArgumentToBeOptional(): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultArgPropertyMissingName = exports.defaultArgElementIsNotAssignment = exports.defaultValueIsNotLiteral = exports.ambiguousNumberType = exports.expectedOneNonNullishType = exports.propertyFieldMissingType = exports.cannotResolveSymbolForDescription = exports.promiseMissingTypeArg = exports.methodMissingType = exports.gqlEntityMissingName = exports.enumVariantMissingInitializer = exports.enumVariantNotStringLiteral = exports.enumTagOnInvalidNode = exports.argNotTyped = exports.argNameNotLiteral = exports.argIsNotProperty = exports.argumentParamIsNotObject = exports.argumentParamIsMissingType = exports.typeNameDoesNotMatchExpected = exports.typeNameTypeNotStringLiteral = exports.typeNameMissingTypeAnnotation = exports.typeNameInitializerWrong = exports.typeNameInitializeNotString = exports.typeNameMissingInitializer = exports.typeNameNotDeclaration = exports.typeTagOnAliasOfNonObjectOrUnknown = exports.typeTagOnUnnamedClass = exports.inputFieldUntyped = exports.inputTypeFieldNotProperty = exports.inputTypeNotLiteral = exports.functionFieldNotNamedExport = exports.functionFieldDefaultExport = exports.functionFieldNotNamed = exports.functionFieldParentTypeNotValid = exports.functionFieldParentTypeMissing = exports.functionFieldNotTopLevel = exports.invalidReturnTypeForFunctionField = exports.invalidParentArgForFunctionField = exports.expectedUnionTypeReference = exports.expectedUnionTypeNode = exports.invalidUnionTagUsage = exports.invalidInputTagUsage = exports.invalidEnumTagUsage = exports.invalidInterfaceTagUsage = exports.invalidScalarTagUsage = exports.invalidTypeTagUsage = exports.invalidGratsTag = exports.wrongCasingForGratsTag = exports.killsParentOnExceptionOnWrongNode = exports.fieldTagOnWrongNode = void 0;
exports.operationTypeNotUnknown = exports.nonSubscriptionFieldAsyncIterable = exports.subscriptionFieldNotAsyncIterable = exports.graphQLTagNameHasWhitespace = exports.graphQLNameHasLeadingNewlines = exports.multipleContextTypes = exports.unexpectedParamSpreadForContextParam = exports.expectedTypeAnnotationOnContextToHaveDeclaration = exports.expectedTypeAnnotationOnContextToBeResolvable = exports.expectedTypeAnnotationOfReferenceOnContext = exports.expectedTypeAnnotationOnContext = exports.unresolvedTypeReference = exports.invalidTypePassedToFieldFunction = exports.parameterPropertyMissingType = exports.parameterPropertyNotPublic = exports.parameterWithoutModifiers = exports.duplicateInterfaceTag = exports.duplicateTag = exports.implementsTagOnTypeAlias = exports.implementsTagOnInterface = exports.implementsTagOnClass = exports.implementsTagMissingValue = exports.mergedInterfaces = exports.nonNullTypeCannotBeOptional = exports.killsParentOnExceptionOnNullable = exports.killsParentOnExceptionWithWrongConfig = exports.expectedIdentifier = exports.pluralTypeMissingParameter = exports.unknownGraphQLType = exports.unsupportedTypeLiteral = exports.defaultArgPropertyMissingInitializer = void 0;
exports.expectedNullableArgumentToBeOptional = exports.operationTypeNotUnknown = exports.nonSubscriptionFieldAsyncIterable = exports.subscriptionFieldNotAsyncIterable = exports.graphQLTagNameHasWhitespace = exports.graphQLNameHasLeadingNewlines = exports.multipleContextTypes = exports.unexpectedParamSpreadForContextParam = exports.expectedTypeAnnotationOnContextToHaveDeclaration = exports.expectedTypeAnnotationOnContextToBeResolvable = exports.expectedTypeAnnotationOfReferenceOnContext = exports.expectedTypeAnnotationOnContext = exports.unresolvedTypeReference = exports.invalidTypePassedToFieldFunction = exports.parameterPropertyMissingType = exports.parameterPropertyNotPublic = exports.parameterWithoutModifiers = exports.duplicateInterfaceTag = exports.duplicateTag = exports.implementsTagOnTypeAlias = exports.implementsTagOnInterface = exports.implementsTagOnClass = exports.implementsTagMissingValue = exports.mergedInterfaces = exports.nonNullTypeCannotBeOptional = exports.killsParentOnExceptionOnNullable = exports.killsParentOnExceptionWithWrongConfig = exports.expectedIdentifier = exports.pluralTypeMissingParameter = exports.unknownGraphQLType = exports.unsupportedTypeLiteral = exports.defaultArgPropertyMissingInitializer = void 0;
var Extractor_1 = require("./Extractor");

@@ -360,1 +360,5 @@ // TODO: Move these to short URLS that are easier to keep from breaking.

exports.operationTypeNotUnknown = operationTypeNotUnknown;
function expectedNullableArgumentToBeOptional() {
return "Expected nullable argument to be optional. graphql-js may not define properties where an undefined argument is passed. To guard against this add a `?` to the end of the argument name to make it optional.";
}
exports.expectedNullableArgumentToBeOptional = expectedNullableArgumentToBeOptional;

@@ -908,9 +908,17 @@ "use strict";

return null;
if (type.kind !== graphql_1.Kind.NON_NULL_TYPE && !node.questionToken) {
// If a field is passed an argument value, and that argument is not defined in the request,
// `graphql-js` will not define the argument property. Therefore we must ensure the argument
// is not just nullable, but optional.
return this.report(node.name, E.expectedNullableArgumentToBeOptional());
}
if (node.questionToken) {
/*
// TODO: Don't allow args that are optional but don't accept null
if (type.kind === Kind.NON_NULL_TYPE) {
return this.report(node.questionToken, E.nonNullTypeCannotBeOptional());
// Question mark means we can handle the argument being undefined in the
// object literal, but if we are going to type the GraphQL arg as
// optional, the code must also be able to handle an explicit null.
//
// TODO: This will catch { a?: string } but not { a?: string | undefined }.
if (type.kind === graphql_1.Kind.NON_NULL_TYPE) {
return this.report(node.questionToken, E.nonNullTypeCannotBeOptional());
}
*/
type = this.gql.nullableType(type);

@@ -917,0 +925,0 @@ }

@@ -13,1 +13,2 @@ import { GraphQLSchema } from "graphql";

export declare function printGratsSDL(schema: GraphQLSchema, config: ConfigOptions): string;
export declare function printSDLWithoutDirectives(schema: GraphQLSchema): string;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.printGratsSDL = exports.printExecutableSchema = void 0;
exports.printSDLWithoutDirectives = exports.printGratsSDL = exports.printExecutableSchema = void 0;
var utils_1 = require("@graphql-tools/utils");

@@ -37,3 +37,5 @@ var graphql_1 = require("graphql");

var includeDirectives = !config.graphqlSchema;
var sdl = printSDL(schema, includeDirectives);
var sdl = includeDirectives
? (0, utils_1.printSchemaWithDirectives)(schema, { assumeValid: true })
: printSDLWithoutDirectives(schema);
if (config.schemaHeader) {

@@ -45,8 +47,3 @@ return "".concat(config.schemaHeader, "\n").concat(sdl);

exports.printGratsSDL = printGratsSDL;
function printSDL(schema, includeDirectives) {
if (includeDirectives) {
return (0, utils_1.printSchemaWithDirectives)(schema, {
assumeValid: true,
});
}
function printSDLWithoutDirectives(schema) {
return (0, graphql_1.printSchema)(new graphql_1.GraphQLSchema(__assign(__assign({}, schema.toConfig()), {

@@ -57,1 +54,2 @@ // TODO: Only filter out our directives. Note that

}
exports.printSDLWithoutDirectives = printSDLWithoutDirectives;

@@ -6,9 +6,9 @@ import { Int } from "../../../Types";

export declare function firstHundredIntegers(_: Query, args: {
first: Int | null;
after: string | null;
first?: Int | null;
after?: string | null;
}): FirstHundredIntegersConnection;
/** @gqlType */
declare class FirstHundredIntegersConnection {
first: number | null;
after: string | null;
first?: number | null | undefined;
after?: string | null | undefined;
_max: number;

@@ -19,3 +19,3 @@ /** @gqlField */

edges: FirstHundredIntegersEdge[];
constructor(first: number | null, after: string | null);
constructor(first?: number | null | undefined, after?: string | null | undefined);
}

@@ -22,0 +22,0 @@ /** @gqlType */

@@ -72,2 +72,4 @@ "use strict";

var utils_1 = require("@graphql-tools/utils");
var jest_diff_1 = require("jest-diff");
var printSchema_1 = require("../printSchema");
var program = new commander_1.Command();

@@ -187,3 +189,3 @@ program

transformer: function (code, fileName) { return __awaiter(void 0, void 0, void 0, function () {
var filePath, schemaPath, options, files, parsedOptions, schemaResult, tsSchema, server, schemaModule, data;
var filePath, schemaPath, options, files, parsedOptions, schemaResult, tsSchema, server, schemaModule, schemaDiff, data;
return __generator(this, function (_a) {

@@ -226,5 +228,12 @@ switch (_a.label) {

schemaModule = _a.sent();
schemaDiff = compareSchemas(schemaModule.schema, schemaResult.value);
if (schemaDiff) {
console.log(schemaDiff);
// TODO: Make this an actual test failure, not an error
throw new Error("The codegen schema does not match the SDL schema.");
}
return [4 /*yield*/, (0, graphql_1.graphql)({
schema: schemaModule.schema,
source: server.query,
variableValues: server.variables,
})];

@@ -253,2 +262,11 @@ case 3:

];
// Returns null if the schemas are equal, otherwise returns a string diff.
function compareSchemas(actual, expected) {
var actualSDL = (0, printSchema_1.printSDLWithoutDirectives)(actual);
var expectedSDL = (0, printSchema_1.printSDLWithoutDirectives)(expected);
if (actualSDL === expectedSDL) {
return null;
}
return (0, jest_diff_1.diff)(expectedSDL, actualSDL);
}
program.parse();
{
"name": "grats",
"version": "0.0.0-main-c81a7c59",
"version": "0.0.0-main-c9e75904",
"main": "dist/src/index.js",

@@ -5,0 +5,0 @@ "bin": "dist/src/cli.js",

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