You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

grats

Package Overview
Dependencies
Maintainers
1
Versions
258
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

to
0.0.0-main-d7c9fa5c

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

2

dist/package.json

@@ -16,3 +16,3 @@ {

"format": "prettier . --write",
"lint": "eslint src/**/*.ts && prettier . --check"
"lint": "eslint . && prettier . --check"
},

@@ -19,0 +19,0 @@ "dependencies": {

@@ -53,2 +53,10 @@ "use strict";

}
Codegen.prototype.createBlockWithScope = function (closure) {
var initialStatements = this._statements;
this._statements = [];
closure();
var block = F.createBlock(this._statements, true);
this._statements = initialStatements;
return block;
};
Codegen.prototype.graphQLImport = function (name) {

@@ -58,4 +66,11 @@ this._graphQLImports.add(name);

};
Codegen.prototype.graphQLTypeImport = function (name) {
this._graphQLImports.add(name);
return F.createTypeReferenceNode(name);
};
Codegen.prototype.schemaDeclaration = function () {
this.constDeclaration("schema", F.createNewExpression(this.graphQLImport("GraphQLSchema"), [], [this.schemaConfig()]));
var _this = this;
this.functionDeclaration("getSchema", this.graphQLTypeImport("GraphQLSchema"), this.createBlockWithScope(function () {
_this._statements.push(F.createReturnStatement(F.createNewExpression(_this.graphQLImport("GraphQLSchema"), [], [_this.schemaConfig()])));
}));
};

@@ -65,3 +80,3 @@ Codegen.prototype.schemaExport = function () {

false, F.createNamedExports([
F.createExportSpecifier(false, undefined, F.createIdentifier("schema")),
F.createExportSpecifier(false, undefined, F.createIdentifier("getSchema")),
])));

@@ -438,2 +453,5 @@ };

};
Codegen.prototype.functionDeclaration = function (name, type, body) {
this._statements.push(F.createFunctionDeclaration(undefined, undefined, name, undefined, [], type, body));
};
// Helper to allow for nullable elements.

@@ -440,0 +458,0 @@ Codegen.prototype.objectLiteral = function (properties) {

@@ -0,1 +1,2 @@

export declare const ISSUE_URL = "https://github.com/captbaritone/grats/issues";
/**

@@ -53,3 +54,3 @@ * Error messages for Grats

export declare function methodMissingType(): string;
export declare function promiseMissingTypeArg(): string;
export declare function wrapperMissingTypeArg(): string;
export declare function cannotResolveSymbolForDescription(): string;

@@ -66,3 +67,3 @@ export declare function propertyFieldMissingType(): string;

export declare function pluralTypeMissingParameter(): string;
export declare function expectedIdentifier(): string;
export declare function expectedNameIdentifier(): string;
export declare function killsParentOnExceptionWithWrongConfig(): string;

@@ -72,3 +73,2 @@ export declare function killsParentOnExceptionOnNullable(): string;

export declare function mergedInterfaces(): string;
export declare function implementsTagMissingValue(): string;
export declare function implementsTagOnClass(): string;

@@ -75,0 +75,0 @@ export declare function implementsTagOnInterface(): 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.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;
exports.defaultArgElementIsNotAssignment = exports.defaultValueIsNotLiteral = exports.ambiguousNumberType = exports.expectedOneNonNullishType = exports.propertyFieldMissingType = exports.cannotResolveSymbolForDescription = exports.wrapperMissingTypeArg = 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 = exports.ISSUE_URL = 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.mergedInterfaces = exports.nonNullTypeCannotBeOptional = exports.killsParentOnExceptionOnNullable = exports.killsParentOnExceptionWithWrongConfig = exports.expectedNameIdentifier = exports.pluralTypeMissingParameter = exports.unknownGraphQLType = exports.unsupportedTypeLiteral = exports.defaultArgPropertyMissingInitializer = exports.defaultArgPropertyMissingName = void 0;
var Extractor_1 = require("./Extractor");
exports.ISSUE_URL = "https://github.com/captbaritone/grats/issues";
// TODO: Move these to short URLS that are easier to keep from breaking.

@@ -39,31 +40,31 @@ var DOC_URLS = {

function invalidTypeTagUsage() {
return "`@".concat(Extractor_1.TYPE_TAG, "` can only be used on class or interface declarations.");
return "`@".concat(Extractor_1.TYPE_TAG, "` can only be used on class, interface or type declarations. e.g. `class MyType {}`");
}
exports.invalidTypeTagUsage = invalidTypeTagUsage;
function invalidScalarTagUsage() {
return "`@".concat(Extractor_1.SCALAR_TAG, "` can only be used on type alias declarations.");
return "`@".concat(Extractor_1.SCALAR_TAG, "` can only be used on type alias declarations. e.g. `type MyScalar = string`");
}
exports.invalidScalarTagUsage = invalidScalarTagUsage;
function invalidInterfaceTagUsage() {
return "`@".concat(Extractor_1.INTERFACE_TAG, "` can only be used on interface declarations.");
return "`@".concat(Extractor_1.INTERFACE_TAG, "` can only be used on interface declarations. e.g. `interface MyInterface {}`");
}
exports.invalidInterfaceTagUsage = invalidInterfaceTagUsage;
function invalidEnumTagUsage() {
return "`@".concat(Extractor_1.ENUM_TAG, "` can only be used on enum declarations or TypeScript unions.");
return "`@".concat(Extractor_1.ENUM_TAG, "` can only be used on enum declarations or TypeScript unions. e.g. `enum MyEnum {}` or `type MyEnum = \"foo\" | \"bar\"`");
}
exports.invalidEnumTagUsage = invalidEnumTagUsage;
function invalidInputTagUsage() {
return "`@".concat(Extractor_1.INPUT_TAG, "` can only be used on type alias declarations.");
return "`@".concat(Extractor_1.INPUT_TAG, "` can only be used on type alias declarations. e.g. `type MyInput = { foo: string }`");
}
exports.invalidInputTagUsage = invalidInputTagUsage;
function invalidUnionTagUsage() {
return "`@".concat(Extractor_1.UNION_TAG, "` can only be used on type alias declarations.");
return "`@".concat(Extractor_1.UNION_TAG, "` can only be used on type alias declarations. e.g. `type MyUnion = TypeA | TypeB`");
}
exports.invalidUnionTagUsage = invalidUnionTagUsage;
function expectedUnionTypeNode() {
return "Expected a TypeScript union. `@".concat(Extractor_1.UNION_TAG, "` can only be used on TypeScript unions.");
return "Expected a TypeScript union. `@".concat(Extractor_1.UNION_TAG, "` can only be used on TypeScript unions. e.g. `type MyUnion = TypeA | TypeB`");
}
exports.expectedUnionTypeNode = expectedUnionTypeNode;
function expectedUnionTypeReference() {
return "Expected `@".concat(Extractor_1.UNION_TAG, "` union members to be type references.");
return "Expected `@".concat(Extractor_1.UNION_TAG, "` union members to be type references. Grats expects union members to be references to something annotated with `@gqlType`.");
}

@@ -76,43 +77,44 @@ exports.expectedUnionTypeReference = expectedUnionTypeReference;

function invalidReturnTypeForFunctionField() {
return "Expected GraphQL field to have an explicit return type.";
return 'Expected GraphQL field to have an explicit return type. This is needed to allow Grats to "see" the type of the field.';
}
exports.invalidReturnTypeForFunctionField = invalidReturnTypeForFunctionField;
function functionFieldNotTopLevel() {
return "Expected `@".concat(Extractor_1.FIELD_TAG, "` function to be a top-level declaration.");
return "Expected `@".concat(Extractor_1.FIELD_TAG, "` function to be a top-level declaration. Grats needs to import resolver functions into it's generated schema module, so the resolver function must be an exported.");
}
exports.functionFieldNotTopLevel = functionFieldNotTopLevel;
var FUNCTION_PARENT_TYPE_CONTEXT = "Grats treats the first argument as the parent object of the field. Therefore Grats needs to see the _type_ of the first argument in order to know to which type/interface this field should be added.";
function functionFieldParentTypeMissing() {
return "Expected first argument of a `@".concat(Extractor_1.FIELD_TAG, "` function to have an explicit type annotation.");
return "Expected first argument of a `@".concat(Extractor_1.FIELD_TAG, "` function to have an explicit type annotation. ").concat(FUNCTION_PARENT_TYPE_CONTEXT);
}
exports.functionFieldParentTypeMissing = functionFieldParentTypeMissing;
function functionFieldParentTypeNotValid() {
return "Expected first argument of a `@".concat(Extractor_1.FIELD_TAG, "` function to be typed as a `@").concat(Extractor_1.TYPE_TAG, "` type.");
return "Expected first argument of a `@".concat(Extractor_1.FIELD_TAG, "` function to be typed as a type reference. ").concat(FUNCTION_PARENT_TYPE_CONTEXT);
}
exports.functionFieldParentTypeNotValid = functionFieldParentTypeNotValid;
function functionFieldNotNamed() {
return "Expected `@".concat(Extractor_1.FIELD_TAG, "` function to be named.");
return "Expected `@".concat(Extractor_1.FIELD_TAG, "` function to be named. Grats uses the name of the function to derive the name of the GraphQL field. Additionally, Grats needs to import resolver functions into it's generated schema module, so the resolver function must be a named export.");
}
exports.functionFieldNotNamed = functionFieldNotNamed;
function functionFieldDefaultExport() {
return "Expected a `@".concat(Extractor_1.FIELD_TAG, "` function to be a named export, not a default export.");
return "Expected a `@".concat(Extractor_1.FIELD_TAG, "` function to be a named export, not a default export. Grats needs to import resolver functions into it's generated schema module, so the resolver function must be a named export.");
}
exports.functionFieldDefaultExport = functionFieldDefaultExport;
function functionFieldNotNamedExport() {
return "Expected a `@".concat(Extractor_1.FIELD_TAG, "` function to be a named export.");
return "Expected a `@".concat(Extractor_1.FIELD_TAG, "` function to be a named export. Grats needs to import resolver functions into it's generated schema module, so the resolver function must be a named export.");
}
exports.functionFieldNotNamedExport = functionFieldNotNamedExport;
function inputTypeNotLiteral() {
return "`@".concat(Extractor_1.INPUT_TAG, "` can only be used on type literals.");
return "`@".concat(Extractor_1.INPUT_TAG, "` can only be used on type literals. e.g. `type MyInput = { foo: string }`");
}
exports.inputTypeNotLiteral = inputTypeNotLiteral;
function inputTypeFieldNotProperty() {
return "`@".concat(Extractor_1.INPUT_TAG, "` types only support property signature members.");
return "`@".concat(Extractor_1.INPUT_TAG, "` types only support property signature members. e.g. `type MyInput = { foo: string }`");
}
exports.inputTypeFieldNotProperty = inputTypeFieldNotProperty;
function inputFieldUntyped() {
return "Input field must have a type annotation.";
return 'Input field must have an explicit type annotation. Grats uses the type annotation to determine the type of the field, so it must be explicit in order for Grats to "see" the type.';
}
exports.inputFieldUntyped = inputFieldUntyped;
function typeTagOnUnnamedClass() {
return "Unexpected `@".concat(Extractor_1.TYPE_TAG, "` annotation on unnamed class declaration.");
return "Unexpected `@".concat(Extractor_1.TYPE_TAG, "` annotation on unnamed class declaration. Grats uses the name of the class to derive the name of the GraphQL type. Consider naming the class.");
}

@@ -125,83 +127,84 @@ exports.typeTagOnUnnamedClass = typeTagOnUnnamedClass;

function typeNameNotDeclaration() {
return "Expected `__typename` to be a property declaration.";
return "Expected `__typename` to be a property declaration. For example: `__typename: \"MyType\"`.";
}
exports.typeNameNotDeclaration = typeNameNotDeclaration;
var TYPENAME_CONTEXT = "This lets Grats know that the GraphQL executor will be able to derive the type of the object at runtime.";
function typeNameMissingInitializer() {
return "Expected `__typename` property to have an initializer or a string literal type. For example: `__typename = \"MyType\"` or `__typename: \"MyType\";`.";
return "Expected `__typename` property to have an initializer or a string literal type. For example: `__typename = \"MyType\"` or `__typename: \"MyType\";`. ".concat(TYPENAME_CONTEXT);
}
exports.typeNameMissingInitializer = typeNameMissingInitializer;
function typeNameInitializeNotString() {
return "Expected `__typename` property initializer to be a string literal. For example: `__typename = \"MyType\"` or `__typename: \"MyType\";`.";
return "Expected `__typename` property initializer to be a string literal. For example: `__typename = \"MyType\"` or `__typename: \"MyType\";`. ".concat(TYPENAME_CONTEXT);
}
exports.typeNameInitializeNotString = typeNameInitializeNotString;
function typeNameInitializerWrong(expected, actual) {
return "Expected `__typename` property initializer to be `\"".concat(expected, "\"`, found `\"").concat(actual, "\"`.");
return "Expected `__typename` property initializer to be `\"".concat(expected, "\"`, found `\"").concat(actual, "\"`. ").concat(TYPENAME_CONTEXT);
}
exports.typeNameInitializerWrong = typeNameInitializerWrong;
function typeNameMissingTypeAnnotation(expected) {
return "Expected `__typename` property signature to specify the typename as a string literal string type. For example `__typename: \"".concat(expected, "\";`");
return "Expected `__typename` property signature to specify the typename as a string literal string type. For example `__typename: \"".concat(expected, "\";`. ").concat(TYPENAME_CONTEXT);
}
exports.typeNameMissingTypeAnnotation = typeNameMissingTypeAnnotation;
function typeNameTypeNotStringLiteral(expected) {
return "Expected `__typename` property signature to specify the typename as a string literal string type. For example `__typename: \"".concat(expected, "\";`");
return "Expected `__typename` property signature to specify the typename as a string literal string type. For example `__typename: \"".concat(expected, "\";`. ").concat(TYPENAME_CONTEXT);
}
exports.typeNameTypeNotStringLiteral = typeNameTypeNotStringLiteral;
function typeNameDoesNotMatchExpected(expected) {
return "Expected `__typename` property to be `\"".concat(expected, "\"`");
return "Expected `__typename` property to be `\"".concat(expected, "\"`. ").concat(TYPENAME_CONTEXT);
}
exports.typeNameDoesNotMatchExpected = typeNameDoesNotMatchExpected;
function argumentParamIsMissingType() {
return "Expected GraphQL field arguments to have a TypeScript type. If there are no arguments, you can use `args: unknown`.";
return "Expected GraphQL field arguments to have an explicit type annotation. If there are no arguments, you can use `args: unknown`. Grats needs to be able to see the type of the arguments to generate a GraphQL schema.";
}
exports.argumentParamIsMissingType = argumentParamIsMissingType;
function argumentParamIsNotObject() {
return "Expected GraphQL field arguments to be typed using a literal object: `{someField: string}`. If there are no arguments, you can use `args: unknown`.";
return "Expected GraphQL field arguments to be typed using an inline literal object: `{someField: string}`. If there are no arguments, you can use `args: unknown`. Grats needs to be able to see the type of the arguments to generate a GraphQL schema.";
}
exports.argumentParamIsNotObject = argumentParamIsNotObject;
function argIsNotProperty() {
return "Expected GraphQL field argument type to be a property signature.";
return "Expected GraphQL field argument type to be a property signature. For example: `{ someField: string }`. Grats needs to be able to see the type of the arguments to generate a GraphQL schema.";
}
exports.argIsNotProperty = argIsNotProperty;
function argNameNotLiteral() {
return "Expected GraphQL field argument names to be a literal.";
return "Expected GraphQL field argument names to be a literal. For example: `{ someField: string }`. Grats needs to be able to see the type of the arguments to generate a GraphQL schema.";
}
exports.argNameNotLiteral = argNameNotLiteral;
function argNotTyped() {
return "Expected GraphQL field argument to have a type.";
return "Expected GraphQL field argument to have an explicit type annotation. For example: `{ someField: string }`. Grats needs to be able to see the type of the arguments to generate a GraphQL schema.";
}
exports.argNotTyped = argNotTyped;
function enumTagOnInvalidNode() {
return "Expected `@".concat(Extractor_1.ENUM_TAG, "` to be a union type, or a string literal in the edge case of a single value enum.");
return "Expected `@".concat(Extractor_1.ENUM_TAG, "` to be a union type, or a string literal in the edge case of a single value enum. For example: `type MyEnum = \"foo\" | \"bar\"` or `type MyEnum = \"foo\"`.");
}
exports.enumTagOnInvalidNode = enumTagOnInvalidNode;
function enumVariantNotStringLiteral() {
return "Expected `@".concat(Extractor_1.ENUM_TAG, "` enum members to be string literal types. For example: `'foo'`.");
return "Expected `@".concat(Extractor_1.ENUM_TAG, "` enum members to be string literal types. For example: `'foo'`. Grats needs to be able to see the concrete value of the enum member to generate the GraphQL schema.");
}
exports.enumVariantNotStringLiteral = enumVariantNotStringLiteral;
function enumVariantMissingInitializer() {
return "Expected `@".concat(Extractor_1.ENUM_TAG, "` enum members to have string literal initializers. For example: `FOO = 'foo'`.");
return "Expected `@".concat(Extractor_1.ENUM_TAG, "` enum members to have string literal initializers. For example: `FOO = 'foo'`. In GraphQL enum values are strings, and Grats needs to be able to see the concrete value of the enum member to generate the GraphQL schema.");
}
exports.enumVariantMissingInitializer = enumVariantMissingInitializer;
function gqlEntityMissingName() {
return "Expected GraphQL entity to have a name.";
return "Expected GraphQL entity to have a name. Grats uses the name of the entity to derive the name of the GraphQL construct.";
}
exports.gqlEntityMissingName = gqlEntityMissingName;
function methodMissingType() {
return "Expected GraphQL field to have a type.";
return "Expected GraphQL field methods to have an explicitly defined return type. Grats needs to be able to see the type of the field to generate its type in the GraphQL schema.";
}
exports.methodMissingType = methodMissingType;
function promiseMissingTypeArg() {
return "Expected type reference to have type arguments.";
function wrapperMissingTypeArg() {
return "Expected wrapper type reference to have type arguments. Grats needs to be able to see the return type in order to generate a GraphQL schema.";
}
exports.promiseMissingTypeArg = promiseMissingTypeArg;
exports.wrapperMissingTypeArg = wrapperMissingTypeArg;
function cannotResolveSymbolForDescription() {
return "Expected TypeScript to be able to resolve this GraphQL entity to a symbol.";
return "Expected TypeScript to be able to resolve this GraphQL entity to a symbol. Is it possible that this type is not defined in this file? Grats needs to follow type references to their declaration in order to determine which GraphQL name is being referenced.";
}
exports.cannotResolveSymbolForDescription = cannotResolveSymbolForDescription;
function propertyFieldMissingType() {
return "Expected GraphQL field to have a type.";
return "Expected GraphQL field to have an explicitly defined type annotation. Grats needs to be able to see the type of the field to generate a field's type in the GraphQL schema.";
}
exports.propertyFieldMissingType = propertyFieldMissingType;
function expectedOneNonNullishType() {
return "Expected exactly one non-nullish type.";
return "Expected exactly one non-nullish type. GraphQL does not support fields returning an arbitrary union of types. Consider defining an explicit `@".concat(Extractor_1.UNION_TAG, "` union type and returning that.");
}

@@ -214,35 +217,35 @@ exports.expectedOneNonNullishType = expectedOneNonNullishType;

function defaultValueIsNotLiteral() {
return "Expected GraphQL field argument default values to be a literal.";
return 'Expected GraphQL field argument default values to be a literal. Grats interprets argument defaults as GraphQL default values, which must be literals. For example: `10` or `"foo"`.';
}
exports.defaultValueIsNotLiteral = defaultValueIsNotLiteral;
function defaultArgElementIsNotAssignment() {
return "Expected object literal property to be a property assignment.";
return "Expected property to be a default assignment. For example: `{ first = 10}`. Grats needs to extract a literal GraphQL value here, and that requires Grats being able to see the literal value in the source code.";
}
exports.defaultArgElementIsNotAssignment = defaultArgElementIsNotAssignment;
function defaultArgPropertyMissingName() {
return "Expected object literal property to have a name.";
return "Expected object literal property to have a name. Grats needs to extract a literal value here, and that requires Grats being able to see the literal value and its field name in the source code.";
}
exports.defaultArgPropertyMissingName = defaultArgPropertyMissingName;
function defaultArgPropertyMissingInitializer() {
return "Expected object literal property to have an initializer. For example: `{ offset = 10}`.";
return "Expected object literal property to have an initializer. For example: `{ offset = 10}`. Grats needs to extract a literal GraphQL value here, and that requires Grats being able to see the literal value in the source code.";
}
exports.defaultArgPropertyMissingInitializer = defaultArgPropertyMissingInitializer;
function unsupportedTypeLiteral() {
return "Unexpected type literal. You may want to define a named GraphQL type elsewhere and reference it here.";
return "Unexpected type literal. Grats expects types in GraphQL positions to be scalar types, or reference a named GraphQL type directly. You may want to define a named GraphQL type elsewhere and reference it here.";
}
exports.unsupportedTypeLiteral = unsupportedTypeLiteral;
function unknownGraphQLType() {
return "Unknown GraphQL type.";
return "Unknown GraphQL type. Grats doe not know how to map this type to a GraphQL type. You may want to define a named GraphQL type elsewhere and reference it here. If you think Grats should be able to infer a GraphQL type from this type, please file an issue.";
}
exports.unknownGraphQLType = unknownGraphQLType;
function pluralTypeMissingParameter() {
return "Expected type reference to have type arguments.";
return "Expected wrapper type reference to have type arguments. Grats needs to be able to see the return type in order to generate a GraphQL schema.";
}
exports.pluralTypeMissingParameter = pluralTypeMissingParameter;
function expectedIdentifier() {
return "Expected an identifier.";
function expectedNameIdentifier() {
return "Expected an name identifier. Grats expected to find a name here which it could use to derive the GraphQL name.";
}
exports.expectedIdentifier = expectedIdentifier;
exports.expectedNameIdentifier = expectedNameIdentifier;
function killsParentOnExceptionWithWrongConfig() {
return "Unexpected `@".concat(Extractor_1.KILLS_PARENT_ON_EXCEPTION_TAG, "` tag. `@").concat(Extractor_1.KILLS_PARENT_ON_EXCEPTION_TAG, "` is only supported when the Grats config `nullableByDefault` is enabled.");
return "Unexpected `@".concat(Extractor_1.KILLS_PARENT_ON_EXCEPTION_TAG, "` tag. `@").concat(Extractor_1.KILLS_PARENT_ON_EXCEPTION_TAG, "` is only supported when the Grats config option `nullableByDefault` is enabled in your `tsconfig.json`.");
}

@@ -255,3 +258,3 @@ exports.killsParentOnExceptionWithWrongConfig = killsParentOnExceptionWithWrongConfig;

function nonNullTypeCannotBeOptional() {
return "Unexpected optional argument that does not also accept `null`. Optional arguments in GraphQL may get passed an explicit `null` value. This means optional arguments must be typed to also accept `null`.";
return "Unexpected optional argument that does not also accept `null`. Optional arguments in GraphQL may get passed an explicit `null` value by the GraphQL executor. This means optional arguments must be typed to also accept `null`. Consider adding `| null` to the end of the argument type.";
}

@@ -269,6 +272,2 @@ exports.nonNullTypeCannotBeOptional = nonNullTypeCannotBeOptional;

exports.mergedInterfaces = mergedInterfaces;
function implementsTagMissingValue() {
return "Expected `@".concat(Extractor_1.IMPLEMENTS_TAG_DEPRECATED, "` to be followed by one or more interface names.");
}
exports.implementsTagMissingValue = implementsTagMissingValue;
function implementsTagOnClass() {

@@ -309,3 +308,3 @@ return "`@".concat(Extractor_1.IMPLEMENTS_TAG_DEPRECATED, "` has been deprecated. Instead use `class MyType implements MyInterface`.");

function parameterPropertyMissingType() {
return "Expected `@".concat(Extractor_1.FIELD_TAG, "` parameter property to have a type annotation.");
return "Expected `@".concat(Extractor_1.FIELD_TAG, "` parameter property to have an explicit type annotation. Grats needs to be able to see the type of the parameter property to generate a GraphQL schema.");
}

@@ -318,11 +317,11 @@ exports.parameterPropertyMissingType = parameterPropertyMissingType;

function unresolvedTypeReference() {
return "This type is not a valid GraphQL type. Did you mean to annotate it's definition with a `/** @gql */` tag such as `/** @gqlType */` or `/** @gqlInput **/`?";
return "Unable to resolve type reference. In order to generate a GraphQL schema, Grats needs to determine which GraphQL type is being referenced. This requires being able to resolve type references to their `@gql` annotated declaration. However this reference could not be resolved. Is it possible that this type is not defined in this file?";
}
exports.unresolvedTypeReference = unresolvedTypeReference;
function expectedTypeAnnotationOnContext() {
return "Expected context parameter to have a type annotation. Grats validates that your context parameter is type-safe by checking all context values reference the same type declaration.";
return "Expected context parameter to have an explicit type annotation. Grats validates that your context parameter is type-safe by checking that all context values reference the same type declaration.";
}
exports.expectedTypeAnnotationOnContext = expectedTypeAnnotationOnContext;
function expectedTypeAnnotationOfReferenceOnContext() {
return "Expected context parameter's type to be a type reference Grats validates that your context parameter is type-safe by checking all context values reference the same type declaration.";
return "Expected context parameter's type to be a type reference. Grats validates that your context parameter is type-safe by checking that all context values reference the same type declaration.";
}

@@ -333,3 +332,3 @@ exports.expectedTypeAnnotationOfReferenceOnContext = expectedTypeAnnotationOfReferenceOnContext;

// TODO: I don't think we have a test case that triggers this error.
return "Unable to resolve context parameter type. Grats validates that your context parameter is type-safe by checking all context values reference the same type declaration.";
return "Unable to resolve context parameter type. Grats validates that your context parameter is type-safe by checking that all context values reference the same type declaration.";
}

@@ -342,3 +341,3 @@ exports.expectedTypeAnnotationOnContextToBeResolvable = expectedTypeAnnotationOnContextToBeResolvable;

function unexpectedParamSpreadForContextParam() {
return "Unexpected spread parameter in context parameter position. Grats expects the context parameter to be a single, explicitly typed, argument.";
return "Unexpected spread parameter in context parameter position. Grats expects the context parameter to be a single, explicitly-typed argument.";
}

@@ -359,16 +358,16 @@ exports.unexpectedParamSpreadForContextParam = unexpectedParamSpreadForContextParam;

function subscriptionFieldNotAsyncIterable() {
return "Expected fields on `Subscription` to return an AsyncIterable.";
return "Expected fields on `Subscription` to return an `AsyncIterable`. Fields on `Subscription` model a subscription, which is a stream of events. Grats expects fields on `Subscription` to return an `AsyncIterable` which can be used to model this stream.";
}
exports.subscriptionFieldNotAsyncIterable = subscriptionFieldNotAsyncIterable;
function nonSubscriptionFieldAsyncIterable() {
return "Unexpected AsyncIterable. Only fields on `Subscription` should return an AsyncIterable.";
return "Unexpected AsyncIterable. Only fields on `Subscription` should return an `AsyncIterable`. Non-subscription fields are only expected to return a single value.";
}
exports.nonSubscriptionFieldAsyncIterable = nonSubscriptionFieldAsyncIterable;
function operationTypeNotUnknown() {
return "Operation types `Query`, `Mutation`, and `Subscription` must be defined as type aliases of `unknown`. E.g. `type Query = unknown`.";
return "Operation types `Query`, `Mutation`, and `Subscription` must be defined as type aliases of `unknown`. E.g. `type Query = unknown`. This is because GraphQL servers do not have an agreed upon way to produce root values, and Grats errs on the side of safety. If you are trying to implement dependency injection, consider using the `context` argument passed to each resolver instead. If you have a strong use case for a concrete root value, please file an issue.";
}
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.";
return "Expected nullable argument to _also_ be optional (`?`). graphql-js may omit properties on the argument object where an undefined GraphQL variable is passed, or if the argument is omitted in the operation text. To ensure your resolver is capable of handing this scenario, add a `?` to the end of the argument name to make it optional. e.g. `{greeting?: string | null}`";
}
exports.expectedNullableArgumentToBeOptional = expectedNullableArgumentToBeOptional;

@@ -9,3 +9,2 @@ import { NameNode } from "graphql";

export declare const LIBRARY_NAME = "Grats";
export declare const ISSUE_URL = "https://github.com/captbaritone/grats/issues";
export declare const TYPE_TAG = "gqlType";

@@ -12,0 +11,0 @@ export declare const FIELD_TAG = "gqlField";

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.extract = exports.ALL_TAGS = exports.KILLS_PARENT_ON_EXCEPTION_TAG = exports.IMPLEMENTS_TAG_DEPRECATED = exports.INPUT_TAG = exports.UNION_TAG = exports.ENUM_TAG = exports.INTERFACE_TAG = exports.SCALAR_TAG = exports.FIELD_TAG = exports.TYPE_TAG = exports.ISSUE_URL = exports.LIBRARY_NAME = exports.LIBRARY_IMPORT_NAME = void 0;
exports.extract = exports.ALL_TAGS = exports.KILLS_PARENT_ON_EXCEPTION_TAG = exports.IMPLEMENTS_TAG_DEPRECATED = exports.INPUT_TAG = exports.UNION_TAG = exports.ENUM_TAG = exports.INTERFACE_TAG = exports.SCALAR_TAG = exports.FIELD_TAG = exports.TYPE_TAG = exports.LIBRARY_NAME = exports.LIBRARY_IMPORT_NAME = void 0;
var graphql_1 = require("graphql");

@@ -40,5 +40,5 @@ var DiagnosticError_1 = require("./utils/DiagnosticError");

var gratsRoot_1 = require("./gratsRoot");
var Errors_1 = require("./Errors");
exports.LIBRARY_IMPORT_NAME = "grats";
exports.LIBRARY_NAME = "Grats";
exports.ISSUE_URL = "https://github.com/captbaritone/grats/issues";
exports.TYPE_TAG = "gqlType";

@@ -252,3 +252,3 @@ exports.FIELD_TAG = "gqlField";

Extractor.prototype.reportUnhandled = function (node, positionKind, message, relatedInformation) {
var suggestion = "If you think ".concat(exports.LIBRARY_NAME, " should be able to infer this ").concat(positionKind, ", please report an issue at ").concat(exports.ISSUE_URL, ".");
var suggestion = "If you think ".concat(exports.LIBRARY_NAME, " should be able to infer this ").concat(positionKind, ", please report an issue at ").concat(Errors_1.ISSUE_URL, ".");
var completedMessage = "".concat(message, "\n\n").concat(suggestion);

@@ -420,3 +420,3 @@ return this.report(node, completedMessage, relatedInformation);

Extractor.prototype.collectInputField = function (node) {
var id = this.expectIdentifier(node.name);
var id = this.expectNameIdentifier(node.name);
if (id == null)

@@ -861,3 +861,3 @@ return null;

}
var name = this.expectIdentifier(node.name);
var name = this.expectNameIdentifier(node.name);
if (name == null)

@@ -1011,3 +1011,3 @@ return null;

// Test for leading newlines using the raw text
var hasLeadingNewlines = /\n/.test(tag.getText().trimEnd());
var hasLeadingNewlines = /\n/.test(trimTrailingCommentLines(tag.getText()));
var hasInternalWhitespace = /\s/.test(commentName);

@@ -1037,3 +1037,3 @@ var validationMessage = graphQLNameValidationMessage(commentName);

}
var id = this.expectIdentifier(node.name);
var id = this.expectNameIdentifier(node.name);
if (id == null)

@@ -1090,3 +1090,3 @@ return null;

var description = this.collectDescription(node);
var id = this.expectIdentifier(node.name);
var id = this.expectNameIdentifier(node.name);
if (id == null)

@@ -1111,3 +1111,3 @@ return null;

if (ts.isTypeReferenceNode(node)) {
var identifier = this.expectIdentifier(node.typeName);
var identifier = this.expectNameIdentifier(node.typeName);
if (identifier == null)

@@ -1118,3 +1118,3 @@ return null;

// TODO: Better error?
return this.report(node, E.promiseMissingTypeArg());
return this.report(node, E.wrapperMissingTypeArg());
}

@@ -1144,3 +1144,3 @@ var t_1 = this.collectType(node.typeArguments[0]);

if (ts.isTypeReferenceNode(node)) {
var identifier = this.expectIdentifier(node.typeName);
var identifier = this.expectNameIdentifier(node.typeName);
if (identifier == null)

@@ -1150,3 +1150,3 @@ return null;

if (node.typeArguments == null || node.typeArguments.length === 0) {
return this.report(node, E.promiseMissingTypeArg());
return this.report(node, E.wrapperMissingTypeArg());
}

@@ -1203,3 +1203,3 @@ return node.typeArguments[0];

var directives = [];
var id = this.expectIdentifier(node.name);
var id = this.expectNameIdentifier(node.name);
if (id == null)

@@ -1276,3 +1276,3 @@ return null;

Extractor.prototype.typeReference = function (node) {
var identifier = this.expectIdentifier(node.typeName);
var identifier = this.expectNameIdentifier(node.typeName);
if (identifier == null)

@@ -1316,7 +1316,7 @@ return null;

};
Extractor.prototype.expectIdentifier = function (node) {
Extractor.prototype.expectNameIdentifier = function (node) {
if (ts.isIdentifier(node)) {
return node;
}
return this.report(node, E.expectedIdentifier());
return this.report(node, E.expectedNameIdentifier());
};

@@ -1334,6 +1334,3 @@ Extractor.prototype.findTag = function (node, tagName) {

});
var message = tagName === exports.IMPLEMENTS_TAG_DEPRECATED
? E.duplicateInterfaceTag()
: E.duplicateTag(tagName);
return this.report(tags[0], message, additionalTags);
return this.report(tags[0], E.duplicateTag(tagName), additionalTags);
}

@@ -1374,1 +1371,6 @@ return tags[0];

}
// Trims any number of whitespace-only lines including any lines that simply
// contain a `*` surrounded by whitespace.
function trimTrailingCommentLines(text) {
return text.replace(/(\s*\n\s*\*?\s*)+$/, "");
}
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var SomeObjType = new graphql_1.GraphQLInputObjectType({
name: "SomeObj",
fields: function () {
return {
a: {
name: "a",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)
}
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
args: {
someObj: {
name: "someObj",
type: new graphql_1.GraphQLNonNull(SomeObjType),
defaultValue: {
a: "Sup"
function getSchema() {
var SomeObjType = new graphql_1.GraphQLInputObjectType({
name: "SomeObj",
fields: function () {
return {
a: {
name: "a",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)
}
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
args: {
someObj: {
name: "someObj",
type: new graphql_1.GraphQLNonNull(SomeObjType),
defaultValue: {
a: "Sup"
}
}
},
resolve: function (source, args) {
return (0, index_1.hello)(source, args);
}
},
resolve: function (source, args) {
return (0, index_1.hello)(source, args);
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, SomeObjType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, SomeObjType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var FirstHundredIntegersPageInfoType = new graphql_1.GraphQLObjectType({
name: "FirstHundredIntegersPageInfo",
fields: function () {
return {
hasNextPage: {
name: "hasNextPage",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean)
},
hasPreviousPage: {
name: "hasPreviousPage",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean)
},
startCursor: {
name: "startCursor",
type: graphql_1.GraphQLString
},
endCursor: {
name: "endCursor",
type: graphql_1.GraphQLString
}
};
}
});
var FirstHundredIntegersEdgeType = new graphql_1.GraphQLObjectType({
name: "FirstHundredIntegersEdge",
fields: function () {
return {
node: {
name: "node",
type: graphql_1.GraphQLInt
},
cursor: {
name: "cursor",
type: graphql_1.GraphQLString
}
};
}
});
var FirstHundredIntegersConnectionType = new graphql_1.GraphQLObjectType({
name: "FirstHundredIntegersConnection",
fields: function () {
return {
pageInfo: {
name: "pageInfo",
type: FirstHundredIntegersPageInfoType
},
edges: {
name: "edges",
type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(FirstHundredIntegersEdgeType))
}
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
firstHundredIntegers: {
name: "firstHundredIntegers",
type: FirstHundredIntegersConnectionType,
args: {
first: {
name: "first",
type: graphql_1.GraphQLInt
function getSchema() {
var FirstHundredIntegersPageInfoType = new graphql_1.GraphQLObjectType({
name: "FirstHundredIntegersPageInfo",
fields: function () {
return {
hasNextPage: {
name: "hasNextPage",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean)
},
hasPreviousPage: {
name: "hasPreviousPage",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLBoolean)
},
startCursor: {
name: "startCursor",
type: graphql_1.GraphQLString
},
endCursor: {
name: "endCursor",
type: graphql_1.GraphQLString
}
};
}
});
var FirstHundredIntegersEdgeType = new graphql_1.GraphQLObjectType({
name: "FirstHundredIntegersEdge",
fields: function () {
return {
node: {
name: "node",
type: graphql_1.GraphQLInt
},
cursor: {
name: "cursor",
type: graphql_1.GraphQLString
}
};
}
});
var FirstHundredIntegersConnectionType = new graphql_1.GraphQLObjectType({
name: "FirstHundredIntegersConnection",
fields: function () {
return {
pageInfo: {
name: "pageInfo",
type: FirstHundredIntegersPageInfoType
},
edges: {
name: "edges",
type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(FirstHundredIntegersEdgeType))
}
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
firstHundredIntegers: {
name: "firstHundredIntegers",
type: FirstHundredIntegersConnectionType,
args: {
first: {
name: "first",
type: graphql_1.GraphQLInt
},
after: {
name: "after",
type: graphql_1.GraphQLString
}
},
after: {
name: "after",
type: graphql_1.GraphQLString
resolve: function (source, args) {
return (0, index_1.firstHundredIntegers)(source, args);
}
},
resolve: function (source, args) {
return (0, index_1.firstHundredIntegers)(source, args);
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, FirstHundredIntegersConnectionType, FirstHundredIntegersPageInfoType, FirstHundredIntegersEdgeType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, FirstHundredIntegersConnectionType, FirstHundredIntegersPageInfoType, FirstHundredIntegersEdgeType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var index_2 = require("./index");
var graphql_1 = require("graphql");
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
deprecationReason: "For reasons",
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.hello)(source);
function getSchema() {
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
deprecationReason: "For reasons",
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.hello)(source);
}
},
goodBye: {
deprecationReason: "No longer supported",
name: "goodBye",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_2.goodBye)(source);
}
}
},
goodBye: {
deprecationReason: "No longer supported",
name: "goodBye",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_2.goodBye)(source);
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
args: {
someArg: {
name: "someArg",
type: graphql_1.GraphQLString,
defaultValue: "Hello"
function getSchema() {
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
args: {
someArg: {
name: "someArg",
type: graphql_1.GraphQLString,
defaultValue: "Hello"
}
},
resolve: function (source, args) {
return (0, index_1.hello)(source, args);
}
},
resolve: function (source, args) {
return (0, index_1.hello)(source, args);
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.hello)(source);
function getSchema() {
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.hello)(source);
}
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.notHello)(source);
function getSchema() {
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.notHello)(source);
}
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var UserType = new graphql_1.GraphQLObjectType({
name: "User",
fields: function () {
return {
alwaysThrowsKillsParentOnException: {
name: "alwaysThrowsKillsParentOnException",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)
}
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
me: {
name: "me",
type: UserType,
resolve: function (source) {
return (0, index_1.me)(source);
function getSchema() {
var UserType = new graphql_1.GraphQLObjectType({
name: "User",
fields: function () {
return {
alwaysThrowsKillsParentOnException: {
name: "alwaysThrowsKillsParentOnException",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString)
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, UserType]
});
exports.schema = schema;
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
me: {
name: "me",
type: UserType,
resolve: function (source) {
return (0, index_1.me)(source);
}
}
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, UserType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var index_2 = require("./index");
var graphql_1 = require("graphql");
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
alwaysThrowsKillsParentOnException: {
name: "alwaysThrowsKillsParentOnException",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
resolve: function (source) {
return (0, index_1.alwaysThrowsKillsParentOnException)(source);
function getSchema() {
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
alwaysThrowsKillsParentOnException: {
name: "alwaysThrowsKillsParentOnException",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLString),
resolve: function (source) {
return (0, index_1.alwaysThrowsKillsParentOnException)(source);
}
},
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_2.hello)(source);
}
}
},
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_2.hello)(source);
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
args: {
someID: {
name: "someID",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID)
function getSchema() {
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
args: {
someID: {
name: "someID",
type: new graphql_1.GraphQLNonNull(graphql_1.GraphQLID)
}
},
resolve: function (source, args) {
return (0, index_1.hello)(source, args);
}
},
resolve: function (source, args) {
return (0, index_1.hello)(source, args);
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var UserType = new graphql_1.GraphQLObjectType({
name: "User",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source, args, context, info) {
return typeof source.NOT_THIS === "function" ? source.NOT_THIS(source, args, context, info) : source.NOT_THIS;
function getSchema() {
var UserType = new graphql_1.GraphQLObjectType({
name: "User",
fields: function () {
return {
hello: {
name: "hello",
type: graphql_1.GraphQLString,
resolve: function (source, args, context, info) {
return typeof source.NOT_THIS === "function" ? source.NOT_THIS(source, args, context, info) : source.NOT_THIS;
}
}
}
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
me: {
name: "me",
type: UserType,
resolve: function (source) {
return (0, index_1.me)(source);
};
}
});
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
me: {
name: "me",
type: UserType,
resolve: function (source) {
return (0, index_1.me)(source);
}
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, UserType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType, UserType]
});
}
exports.getSchema = getSchema;
import { GraphQLSchema } from "graphql";
declare const schema: GraphQLSchema;
export { schema };
declare function getSchema(): GraphQLSchema;
export { getSchema };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.schema = void 0;
exports.getSchema = void 0;
var index_1 = require("./index");
var graphql_1 = require("graphql");
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
alwaysThrows: {
name: "alwaysThrows",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.alwaysThrows)(source);
function getSchema() {
var QueryType = new graphql_1.GraphQLObjectType({
name: "Query",
fields: function () {
return {
alwaysThrows: {
name: "alwaysThrows",
type: graphql_1.GraphQLString,
resolve: function (source) {
return (0, index_1.alwaysThrows)(source);
}
}
}
};
}
});
var schema = new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
exports.schema = schema;
};
}
});
return new graphql_1.GraphQLSchema({
query: QueryType,
types: [QueryType]
});
}
exports.getSchema = getSchema;

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

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

@@ -230,3 +230,4 @@ switch (_a.label) {

schemaModule = _a.sent();
schemaDiff = compareSchemas(schemaModule.schema, schemaResult.value);
actualSchema = schemaModule.getSchema();
schemaDiff = compareSchemas(actualSchema, schemaResult.value);
if (schemaDiff) {

@@ -238,3 +239,3 @@ console.log(schemaDiff);

return [4 /*yield*/, (0, graphql_1.graphql)({
schema: schemaModule.schema,
schema: actualSchema,
source: server.query,

@@ -241,0 +242,0 @@ variableValues: server.variables,

@@ -27,16 +27,24 @@ "use strict";

var symbol = checker.getSymbolAtLocation(node.name);
if (symbol != null &&
symbol.declarations != null &&
symbol.declarations.length > 1) {
var otherLocations = symbol.declarations
.filter(function (d) { return d !== node && ts.isInterfaceDeclaration(d); })
.map(function (d) {
var _a;
var locNode = (_a = ts.getNameOfDeclaration(d)) !== null && _a !== void 0 ? _a : d;
return (0, DiagnosticError_1.tsRelated)(locNode, "Other declaration");
});
if (otherLocations.length > 0) {
errors.push((0, DiagnosticError_1.tsErr)(node.name, E.mergedInterfaces(), otherLocations));
}
if (symbol == null) {
return "continue";
}
// @ts-ignore Exposed as public in https://github.com/microsoft/TypeScript/pull/56193
var mergedSymbol = checker.getMergedSymbol(symbol);
if (mergedSymbol.declarations == null ||
mergedSymbol.declarations.length < 2) {
return "continue";
}
var otherLocations = mergedSymbol.declarations
.filter(function (d) {
return d !== node &&
(ts.isInterfaceDeclaration(d) || ts.isClassDeclaration(d));
})
.map(function (d) {
var _a;
var locNode = (_a = ts.getNameOfDeclaration(d)) !== null && _a !== void 0 ? _a : d;
return (0, DiagnosticError_1.tsRelated)(locNode, "Other declaration");
});
if (otherLocations.length > 0) {
errors.push((0, DiagnosticError_1.tsErr)(node.name, E.mergedInterfaces(), otherLocations));
}
};

@@ -43,0 +51,0 @@ try {

{
"name": "grats",
"version": "0.0.0-main-d4d43d4b",
"version": "0.0.0-main-d7c9fa5c",
"main": "dist/src/index.js",

@@ -42,4 +42,4 @@ "bin": "dist/src/cli.js",

"format": "prettier . --write",
"lint": "eslint src/**/*.ts && prettier . --check"
"lint": "eslint . && prettier . --check"
}
}