├── .eslintignore ├── .eslintrc.cjs ├── .github └── workflows │ └── ci.yaml ├── .gitignore ├── .npmrc ├── .prettierignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── examples ├── README.md ├── apollo-server │ ├── Query.ts │ ├── README.md │ ├── interfaces │ │ └── IPerson.ts │ ├── models │ │ ├── Group.ts │ │ └── User.ts │ ├── package.json │ ├── schema.graphql │ ├── schema.ts │ ├── server.ts │ └── tsconfig.json ├── express-graphql-http │ ├── README.md │ ├── interfaces │ │ └── IPerson.ts │ ├── models │ │ ├── Group.ts │ │ └── User.ts │ ├── package.json │ ├── schema.graphql │ ├── schema.ts │ ├── server.ts │ └── tsconfig.json ├── express-graphql │ ├── README.md │ ├── interfaces │ │ └── IPerson.ts │ ├── models │ │ ├── Group.ts │ │ └── User.ts │ ├── package.json │ ├── schema.graphql │ ├── schema.ts │ ├── server.ts │ └── tsconfig.json ├── incremental-migration │ ├── README.md │ ├── gratsSchema.graphql │ ├── models.ts │ ├── package.json │ ├── schema.graphql │ ├── schemas │ │ ├── gratsGeneratedSchema.ts │ │ ├── mergedSchema.ts │ │ └── pothosSchema.ts │ ├── server.ts │ ├── testConfig.json │ └── tsconfig.json ├── next-js │ ├── .gitignore │ ├── README.md │ ├── app │ │ ├── api │ │ │ └── graphql │ │ │ │ ├── Query.ts │ │ │ │ ├── interfaces │ │ │ │ └── IPerson.ts │ │ │ │ ├── models │ │ │ │ ├── Group.ts │ │ │ │ └── User.ts │ │ │ │ └── route.ts │ │ ├── layout.tsx │ │ └── page.tsx │ ├── next.config.js │ ├── package.json │ ├── schema.graphql │ ├── schema.ts │ ├── testConfig.json │ └── tsconfig.json ├── production-app │ ├── Database.ts │ ├── PubSub.ts │ ├── README.md │ ├── ViewerContext.ts │ ├── graphql │ │ ├── Connection.ts │ │ ├── CustomScalars.ts │ │ ├── Node.ts │ │ ├── directives.ts │ │ └── gqlUtils.ts │ ├── models │ │ ├── Like.ts │ │ ├── LikeConnection.ts │ │ ├── Model.ts │ │ ├── Post.ts │ │ ├── PostConnection.ts │ │ ├── User.ts │ │ ├── UserConnection.ts │ │ └── Viewer.ts │ ├── package.json │ ├── schema.graphql │ ├── schema.ts │ ├── server.ts │ ├── testConfig.json │ └── tsconfig.json ├── strict-semantic-nullability │ ├── README.md │ ├── Subscription.ts │ ├── interfaces │ │ └── IPerson.ts │ ├── models │ │ ├── Group.ts │ │ └── User.ts │ ├── package.json │ ├── schema.graphql │ ├── schema.ts │ ├── server.ts │ └── tsconfig.json └── yoga │ ├── README.md │ ├── Subscription.ts │ ├── interfaces │ └── IPerson.ts │ ├── models │ ├── Group.ts │ └── User.ts │ ├── package.json │ ├── schema.graphql │ ├── schema.ts │ ├── server.ts │ └── tsconfig.json ├── grats-ts-plugin ├── README.md ├── index.js └── package.json ├── package.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── scripts └── release.sh ├── src ├── CodeActions.ts ├── Errors.ts ├── Extractor.ts ├── GraphQLAstExtensions.ts ├── GraphQLConstructor.ts ├── InterfaceGraph.ts ├── Locate.ts ├── TypeContext.ts ├── Types.ts ├── cli.ts ├── codegen │ ├── TSAstBuilder.ts │ ├── resolverCodegen.ts │ ├── resolverMapCodegen.ts │ └── schemaCodegen.ts ├── codegenHelpers.ts ├── comments.ts ├── gratsConfig.ts ├── gratsRoot.ts ├── index.ts ├── lib.ts ├── metadata.ts ├── printSchema.ts ├── publicDirectives.ts ├── resolverSignature.ts ├── tests │ ├── TestRunner.ts │ ├── fixtures │ │ ├── arguments │ │ │ ├── ArgReferencesNonGqlType.invalid.ts │ │ │ ├── ArgReferencesNonGqlType.invalid.ts.expected │ │ │ ├── ArgWithNoType.invalid.ts │ │ │ ├── ArgWithNoType.invalid.ts.expected │ │ │ ├── ArgumentWithDescription.ts │ │ │ ├── ArgumentWithDescription.ts.expected │ │ │ ├── AsyncIterableArgument.invalid.ts │ │ │ ├── AsyncIterableArgument.invalid.ts.expected │ │ │ ├── CustomScalarArgument.ts │ │ │ ├── CustomScalarArgument.ts.expected │ │ │ ├── DeprecatedArgument.ts │ │ │ ├── DeprecatedArgument.ts.expected │ │ │ ├── DeprecatedRequiredArgument.invalid.ts │ │ │ ├── DeprecatedRequiredArgument.invalid.ts.expected │ │ │ ├── GqlTypeUsedAsPositionalArg.ts │ │ │ ├── GqlTypeUsedAsPositionalArg.ts.expected │ │ │ ├── MultipleParamsTypedAsTypeLiteral.ts │ │ │ ├── MultipleParamsTypedAsTypeLiteral.ts.expected │ │ │ ├── NoArgsWithNever.ts │ │ │ ├── NoArgsWithNever.ts.expected │ │ │ ├── NoArgsWithUnknown.invalid.ts │ │ │ ├── NoArgsWithUnknown.invalid.ts.expected │ │ │ ├── NoTypeAnnotation.invalid.ts │ │ │ ├── NoTypeAnnotation.invalid.ts.expected │ │ │ ├── NullableArgumentErrors.invalid.ts │ │ │ ├── NullableArgumentErrors.invalid.ts.expected │ │ │ ├── NullableArguments.ts │ │ │ ├── NullableArguments.ts.expected │ │ │ ├── ObjectLiteralArgument.invalid.ts │ │ │ ├── ObjectLiteralArgument.invalid.ts.expected │ │ │ ├── OpaqueArgType.invalid.ts │ │ │ ├── OpaqueArgType.invalid.ts.expected │ │ │ ├── OptionalArgument.ts │ │ │ ├── OptionalArgument.ts.expected │ │ │ ├── OptionalNonNullableArgumentWithDefault.ts │ │ │ ├── OptionalNonNullableArgumentWithDefault.ts.expected │ │ │ ├── PositionalArgAndArgs.invalid.ts │ │ │ ├── PositionalArgAndArgs.invalid.ts.expected │ │ │ ├── PositionalArgDeprecatedOptional.ts │ │ │ ├── PositionalArgDeprecatedOptional.ts.expected │ │ │ ├── PositionalArgDeprecatedWithDefault.ts │ │ │ ├── PositionalArgDeprecatedWithDefault.ts.expected │ │ │ ├── PositionalArgOptional.ts │ │ │ ├── PositionalArgOptional.ts.expected │ │ │ ├── PositionalArgOptionalNotNullable.invalid.ts │ │ │ ├── PositionalArgOptionalNotNullable.invalid.ts.expected │ │ │ ├── PositionalArgWithDefault.ts │ │ │ ├── PositionalArgWithDefault.ts.expected │ │ │ ├── PositionalArgWithDescription.ts │ │ │ ├── PositionalArgWithDescription.ts.expected │ │ │ ├── PromiseArgument.invalid.ts │ │ │ ├── PromiseArgument.invalid.ts.expected │ │ │ ├── StringArgument.ts │ │ │ ├── StringArgument.ts.expected │ │ │ ├── TupleLiteralArgument.invalid.ts │ │ │ └── TupleLiteralArgument.invalid.ts.expected │ │ ├── built_in_scalars │ │ │ ├── FloatField.ts │ │ │ ├── FloatField.ts.expected │ │ │ ├── FloatFieldAliasedImport.ts │ │ │ ├── FloatFieldAliasedImport.ts.expected │ │ │ ├── IdField.ts │ │ │ ├── IdField.ts.expected │ │ │ ├── IntField.ts │ │ │ └── IntField.ts.expected │ │ ├── comments │ │ │ ├── blockCommentThreeStars.invalid.ts │ │ │ ├── blockCommentThreeStars.invalid.ts.expected │ │ │ ├── commentFollowsDecorator.invalid.ts │ │ │ ├── commentFollowsDecorator.invalid.ts.expected │ │ │ ├── detachedBlockComment.invalid.ts │ │ │ ├── detachedBlockComment.invalid.ts.expected │ │ │ ├── detachedBlockCommentNotJSDocWithoutStar.invalid.ts │ │ │ ├── detachedBlockCommentNotJSDocWithoutStar.invalid.ts.expected │ │ │ ├── detachedBlockCommentWithInvalidTagName.invalid.ts │ │ │ ├── detachedBlockCommentWithInvalidTagName.invalid.ts.expected │ │ │ ├── detachedBlockCommentWithKillsParent.invalid.ts │ │ │ ├── detachedBlockCommentWithKillsParent.invalid.ts.expected │ │ │ ├── detachedBlockCommentWithoutStar.invalid.ts │ │ │ ├── detachedBlockCommentWithoutStar.invalid.ts.expected │ │ │ ├── invalidTagInLinecomment.ts │ │ │ ├── invalidTagInLinecomment.ts.expected │ │ │ ├── lineComment.invalid.ts │ │ │ ├── lineComment.invalid.ts.expected │ │ │ ├── lineCommentWrongCasing.invalid.ts │ │ │ ├── lineCommentWrongCasing.invalid.ts.expected │ │ │ ├── nonJSDocBlockComment.invalid.ts │ │ │ └── nonJSDocBlockComment.invalid.ts.expected │ │ ├── configOptions │ │ │ ├── headerIsArrayWithNumber.invalid.ts │ │ │ ├── headerIsArrayWithNumber.invalid.ts.expected │ │ │ ├── importModuleSpecifierEnding.ts │ │ │ ├── importModuleSpecifierEnding.ts.expected │ │ │ ├── invalidKey.invalid.ts │ │ │ ├── invalidKey.invalid.ts.expected │ │ │ ├── multipleInvalidKeys.invalid.ts │ │ │ ├── multipleInvalidKeys.invalid.ts.expected │ │ │ ├── nonNullableIsNull.invalid.ts │ │ │ └── nonNullableIsNull.invalid.ts.expected │ │ ├── custom_scalars │ │ │ ├── DefineCustomScalar.ts │ │ │ ├── DefineCustomScalar.ts.expected │ │ │ ├── DefineCustomScalarWithDescription.ts │ │ │ ├── DefineCustomScalarWithDescription.ts.expected │ │ │ ├── DefineRenamedCustomScalar.ts │ │ │ ├── DefineRenamedCustomScalar.ts.expected │ │ │ ├── SpecifiedBy.ts │ │ │ ├── SpecifiedBy.ts.expected │ │ │ ├── SpecifiedByMissingUrlinvalid.ts │ │ │ ├── SpecifiedByMissingUrlinvalid.ts.expected │ │ │ ├── SpecifiedByOldSyntax.invalid.ts │ │ │ ├── SpecifiedByOldSyntax.invalid.ts.expected │ │ │ ├── SpecifiedByOnEnum.invalid.ts │ │ │ ├── SpecifiedByOnEnum.invalid.ts.expected │ │ │ ├── TagAttachedToWrongNode.ts │ │ │ └── TagAttachedToWrongNode.ts.expected │ │ ├── default_values │ │ │ ├── DefaultArgumentArray.ts │ │ │ ├── DefaultArgumentArray.ts.expected │ │ │ ├── DefaultArgumentArrayValuesInvalid.invalid.ts │ │ │ ├── DefaultArgumentArrayValuesInvalid.invalid.ts.expected │ │ │ ├── DefaultArgumentBooleanLiteral.ts │ │ │ ├── DefaultArgumentBooleanLiteral.ts.expected │ │ │ ├── DefaultArgumentNullLiteral.ts │ │ │ ├── DefaultArgumentNullLiteral.ts.expected │ │ │ ├── DefaultArgumentNumberLiteral.ts │ │ │ ├── DefaultArgumentNumberLiteral.ts.expected │ │ │ ├── DefaultArgumentObjectLiteral.ts │ │ │ ├── DefaultArgumentObjectLiteral.ts.expected │ │ │ ├── DefaultArgumentObjectLiteralDynamicPropertyName.invalid.ts │ │ │ ├── DefaultArgumentObjectLiteralDynamicPropertyName.invalid.ts.expected │ │ │ ├── DefaultArgumentObjectLiteralInterpolation.ts │ │ │ ├── DefaultArgumentObjectLiteralInterpolation.ts.expected │ │ │ ├── DefaultArgumentObjectLiteralMultiplePropertyErrors.invalid.ts │ │ │ ├── DefaultArgumentObjectLiteralMultiplePropertyErrors.invalid.ts.expected │ │ │ ├── DefaultArgumentObjectLiteralSpread.invalid.ts │ │ │ ├── DefaultArgumentObjectLiteralSpread.invalid.ts.expected │ │ │ ├── DefaultArgumentPropertyName.ts │ │ │ ├── DefaultArgumentPropertyName.ts.expected │ │ │ ├── DefaultArgumentStringLiteral.ts │ │ │ ├── DefaultArgumentStringLiteral.ts.expected │ │ │ ├── DefaultArgumentStringLiteralBackticks.ts │ │ │ ├── DefaultArgumentStringLiteralBackticks.ts.expected │ │ │ ├── DefaultArgumentStringLiteralBackticksInterpolated.invalid.ts │ │ │ ├── DefaultArgumentStringLiteralBackticksInterpolated.invalid.ts.expected │ │ │ ├── NonLiteralDefaultValue.invalid.ts │ │ │ └── NonLiteralDefaultValue.invalid.ts.expected │ │ ├── derived_context │ │ │ ├── cyclicContextDependency.invalid.ts │ │ │ ├── cyclicContextDependency.invalid.ts.expected │ │ │ ├── cyclicContextDependencyWithChain.invalid.ts │ │ │ ├── cyclicContextDependencyWithChain.invalid.ts.expected │ │ │ ├── derivedContextChain.ts │ │ │ ├── derivedContextChain.ts.expected │ │ │ ├── derivedContextNoReturnType.invalid.ts │ │ │ ├── derivedContextNoReturnType.invalid.ts.expected │ │ │ ├── derivedContextNonNamedReturnType.invalid.ts │ │ │ ├── derivedContextNonNamedReturnType.invalid.ts.expected │ │ │ ├── derivedContextUsedMultipleTimes.ts │ │ │ ├── derivedContextUsedMultipleTimes.ts.expected │ │ │ ├── multipleDerivedContextsSameType.invalid.ts │ │ │ ├── multipleDerivedContextsSameType.invalid.ts.expected │ │ │ ├── simpleDerivedContext.ts │ │ │ ├── simpleDerivedContext.ts.expected │ │ │ ├── simpleDerivedContextNoArgs.ts │ │ │ ├── simpleDerivedContextNoArgs.ts.expected │ │ │ ├── simpleDerivedContextReadsRandomType.invalid.ts │ │ │ ├── simpleDerivedContextReadsRandomType.invalid.ts.expected │ │ │ ├── simpleDerivedContextUndefinedType.invalid.ts │ │ │ └── simpleDerivedContextUndefinedType.invalid.ts.expected │ │ ├── descriptions │ │ │ ├── BlankLinesAroundDescription.ts │ │ │ ├── BlankLinesAroundDescription.ts.expected │ │ │ ├── BlankLinesFollowTypeTag.ts │ │ │ ├── BlankLinesFollowTypeTag.ts.expected │ │ │ ├── DescriptionFollowsTypeTag.invalid.ts │ │ │ ├── DescriptionFollowsTypeTag.invalid.ts.expected │ │ │ ├── DescriptionOnLineOfTypeTag.invalid.ts │ │ │ ├── DescriptionOnLineOfTypeTag.invalid.ts.expected │ │ │ ├── DescriptionWithGitHubHandle.ts │ │ │ ├── DescriptionWithGitHubHandle.ts.expected │ │ │ ├── MultilineDescription.ts │ │ │ ├── MultilineDescription.ts.expected │ │ │ ├── RenameFollowedByDescription.invalid.ts │ │ │ └── RenameFollowedByDescription.invalid.ts.expected │ │ ├── directives │ │ │ ├── defineCustomDirective.ts │ │ │ ├── defineCustomDirective.ts.expected │ │ │ ├── defineCustomDirectiveAdditionalArgsAreIgnored.ts │ │ │ ├── defineCustomDirectiveAdditionalArgsAreIgnored.ts.expected │ │ │ ├── defineCustomDirectiveArgsIsNever.ts │ │ │ ├── defineCustomDirectiveArgsIsNever.ts.expected │ │ │ ├── defineCustomDirectiveCustomName.ts │ │ │ ├── defineCustomDirectiveCustomName.ts.expected │ │ │ ├── defineCustomDirectiveLocationInvalid.invalid.ts │ │ │ ├── defineCustomDirectiveLocationInvalid.invalid.ts.expected │ │ │ ├── defineCustomDirectiveMultipleLocations.ts │ │ │ ├── defineCustomDirectiveMultipleLocations.ts.expected │ │ │ ├── defineCustomDirectiveNoLocation.invalid.ts │ │ │ ├── defineCustomDirectiveNoLocation.invalid.ts.expected │ │ │ ├── defineCustomDirectiveOnIsNotString.ts │ │ │ ├── defineCustomDirectiveOnIsNotString.ts.expected │ │ │ ├── defineCustomDirectiveReadsContext.invalid.ts │ │ │ ├── defineCustomDirectiveReadsContext.invalid.ts.expected │ │ │ ├── defineCustomDirectiveRepeatable.ts │ │ │ ├── defineCustomDirectiveRepeatable.ts.expected │ │ │ ├── defineCustomDirectiveWithArgs.ts │ │ │ ├── defineCustomDirectiveWithArgs.ts.expected │ │ │ ├── defineCustomDirectiveWithArgsNonScalar.ts │ │ │ ├── defineCustomDirectiveWithArgsNonScalar.ts.expected │ │ │ ├── defineCustomDirectiveWithArgsWithDefault.ts │ │ │ ├── defineCustomDirectiveWithArgsWithDefault.ts.expected │ │ │ ├── directiveArgFieldInvalid.invalid.ts │ │ │ ├── directiveArgFieldInvalid.invalid.ts.expected │ │ │ ├── directiveArgInvalidOneOf.invalid.ts │ │ │ ├── directiveArgInvalidOneOf.invalid.ts.expected │ │ │ ├── directiveArgumentNameIsStringLiteralWithDefault.ts │ │ │ ├── directiveArgumentNameIsStringLiteralWithDefault.ts.expected │ │ │ ├── directiveNotConst.invalid.ts │ │ │ ├── directiveNotConst.invalid.ts.expected │ │ │ ├── directiveOnArgumentDefinition.ts │ │ │ ├── directiveOnArgumentDefinition.ts.expected │ │ │ ├── directiveOnEnum.ts │ │ │ ├── directiveOnEnum.ts.expected │ │ │ ├── directiveOnEnumValue.ts │ │ │ ├── directiveOnEnumValue.ts.expected │ │ │ ├── directiveOnFieldDefinition.ts │ │ │ ├── directiveOnFieldDefinition.ts.expected │ │ │ ├── directiveOnInputFieldDefinition.ts │ │ │ ├── directiveOnInputFieldDefinition.ts.expected │ │ │ ├── directiveOnInputObjectType.ts │ │ │ ├── directiveOnInputObjectType.ts.expected │ │ │ ├── directiveOnInterface.ts │ │ │ ├── directiveOnInterface.ts.expected │ │ │ ├── directiveOnObjectType.ts │ │ │ ├── directiveOnObjectType.ts.expected │ │ │ ├── directiveOnScalar.ts │ │ │ ├── directiveOnScalar.ts.expected │ │ │ ├── directiveOnUnion.ts │ │ │ ├── directiveOnUnion.ts.expected │ │ │ ├── directiveUsedWithInvalidArgs.invalid.ts │ │ │ ├── directiveUsedWithInvalidArgs.invalid.ts.expected │ │ │ ├── directiveWithSyntaxError.invalid.ts │ │ │ ├── directiveWithSyntaxError.invalid.ts.expected │ │ │ ├── gqlAnnotateOnNonGqlDocblock.ts │ │ │ ├── gqlAnnotateOnNonGqlDocblock.ts.expected │ │ │ ├── undefinedDirectiveWithArgs.invalid.ts │ │ │ ├── undefinedDirectiveWithArgs.invalid.ts.expected │ │ │ ├── undefinedDirectiveWithoutArgs.ts │ │ │ └── undefinedDirectiveWithoutArgs.ts.expected │ │ ├── enums │ │ │ ├── DeprecatedEnumVariant.ts │ │ │ ├── DeprecatedEnumVariant.ts.expected │ │ │ ├── Enum.ts │ │ │ ├── Enum.ts.expected │ │ │ ├── EnumFromUnionType.ts │ │ │ ├── EnumFromUnionType.ts.expected │ │ │ ├── EnumFromUnionTypeNotLiteral.invalid.ts │ │ │ ├── EnumFromUnionTypeNotLiteral.invalid.ts.expected │ │ │ ├── EnumFromUnionTypeNotStringLiteral.invalid.ts │ │ │ ├── EnumFromUnionTypeNotStringLiteral.invalid.ts.expected │ │ │ ├── EnumFromUnionTypeOfStringLiteral.ts │ │ │ ├── EnumFromUnionTypeOfStringLiteral.ts.expected │ │ │ ├── EnumFromUnionTypeWithDescription.ts │ │ │ ├── EnumFromUnionTypeWithDescription.ts.expected │ │ │ ├── EnumNotValidIdentifier.invalid.ts │ │ │ ├── EnumNotValidIdentifier.invalid.ts.expected │ │ │ ├── EnumValuesDifferentThanNames.ts │ │ │ ├── EnumValuesDifferentThanNames.ts.expected │ │ │ ├── EnumWithDescription.ts │ │ │ ├── EnumWithDescription.ts.expected │ │ │ ├── EnumWithVariantWithDescription.ts │ │ │ ├── EnumWithVariantWithDescription.ts.expected │ │ │ ├── ExplicitlyNumericEnum.ts │ │ │ ├── ExplicitlyNumericEnum.ts.expected │ │ │ ├── ImplicitlyNumericEnum.ts │ │ │ ├── ImplicitlyNumericEnum.ts.expected │ │ │ ├── NonNullEnumDefault.ts │ │ │ ├── NonNullEnumDefault.ts.expected │ │ │ ├── NonNullEnumDefaultInInputObject.ts │ │ │ ├── NonNullEnumDefaultInInputObject.ts.expected │ │ │ ├── NonNullPluralEnumDefaults.ts │ │ │ ├── NonNullPluralEnumDefaults.ts.expected │ │ │ ├── NonNullTsEnumDefault.ts │ │ │ ├── NonNullTsEnumDefault.ts.expected │ │ │ ├── NonNullTsEnumDefaultStringLiteral.ts │ │ │ └── NonNullTsEnumDefaultStringLiteral.ts.expected │ │ ├── examples │ │ │ ├── playground.ts │ │ │ ├── playground.ts.expected │ │ │ ├── readme.ts │ │ │ └── readme.ts.expected │ │ ├── extend_interface │ │ │ ├── addStringFieldToEnum.invalid.ts │ │ │ ├── addStringFieldToEnum.invalid.ts.expected │ │ │ ├── addStringFieldToInterface.ts │ │ │ ├── addStringFieldToInterface.ts.expected │ │ │ ├── addStringFieldToInterfaceImplementedByInterface.ts │ │ │ ├── addStringFieldToInterfaceImplementedByInterface.ts.expected │ │ │ ├── addStringFieldToInterfaceTwice.invalid.ts │ │ │ ├── addStringFieldToInterfaceTwice.invalid.ts.expected │ │ │ ├── addStringFieldToNonGrats.invalid.ts │ │ │ ├── addStringFieldToNonGrats.invalid.ts.expected │ │ │ ├── redefineFiledThatExistsOnConcreteType.invalid.ts │ │ │ ├── redefineFiledThatExistsOnConcreteType.invalid.ts.expected │ │ │ ├── redefineFiledThatExistsOnImplementingInterface.invalid.ts │ │ │ └── redefineFiledThatExistsOnImplementingInterface.invalid.ts.expected │ │ ├── extend_type │ │ │ ├── addDeprecatedField.ts │ │ │ ├── addDeprecatedField.ts.expected │ │ │ ├── addFieldWithArguments.ts │ │ │ ├── addFieldWithArguments.ts.expected │ │ │ ├── addFieldWithDescription.ts │ │ │ ├── addFieldWithDescription.ts.expected │ │ │ ├── addRenamedFieldToSomeType.ts │ │ │ ├── addRenamedFieldToSomeType.ts.expected │ │ │ ├── addStringFieldToSomeType.ts │ │ │ ├── addStringFieldToSomeType.ts.expected │ │ │ ├── defaultExport.ts │ │ │ ├── defaultExport.ts.expected │ │ │ ├── fieldAsArrowFunctionLet.invalid.ts │ │ │ ├── fieldAsArrowFunctionLet.invalid.ts.expected │ │ │ ├── fieldAsArrowFunctionNotExported.invalid.ts │ │ │ ├── fieldAsArrowFunctionNotExported.invalid.ts.expected │ │ │ ├── fieldAsArrowFunctionVar.invalid.ts │ │ │ ├── fieldAsArrowFunctionVar.invalid.ts.expected │ │ │ ├── fieldAsExportedArrowFunction.ts │ │ │ ├── fieldAsExportedArrowFunction.ts.expected │ │ │ ├── fieldAsExportedArrowFunctionPositionalArgs.ts │ │ │ ├── fieldAsExportedArrowFunctionPositionalArgs.ts.expected │ │ │ ├── fieldAsExportedAsyncArrowFunction.ts │ │ │ ├── fieldAsExportedAsyncArrowFunction.ts.expected │ │ │ ├── fieldAsExportedMultipleVariables.invalid.ts │ │ │ ├── fieldAsExportedMultipleVariables.invalid.ts.expected │ │ │ ├── fieldAsExportedNothing.invalid.ts │ │ │ ├── fieldAsExportedNothing.invalid.ts.expected │ │ │ ├── fieldAsExportedNumber.invalid.ts │ │ │ ├── fieldAsExportedNumber.invalid.ts.expected │ │ │ ├── functionFieldOnTypeDefinedWithInterface.ts │ │ │ ├── functionFieldOnTypeDefinedWithInterface.ts.expected │ │ │ ├── interfaceFirstArgumentType.ts │ │ │ ├── interfaceFirstArgumentType.ts.expected │ │ │ ├── missingFirstArgument.invalid.ts │ │ │ ├── missingFirstArgument.invalid.ts.expected │ │ │ ├── missingFirstArgumentType.invalid.ts │ │ │ ├── missingFirstArgumentType.invalid.ts.expected │ │ │ ├── nonAliasFirstArgumentType.invalid.ts │ │ │ ├── nonAliasFirstArgumentType.invalid.ts.expected │ │ │ ├── nonGQLFirstArgumentType.invalid.ts │ │ │ ├── nonGQLFirstArgumentType.invalid.ts.expected │ │ │ ├── notExported.invalid.ts │ │ │ ├── notExported.invalid.ts.expected │ │ │ ├── optionalModelType.ts │ │ │ └── optionalModelType.ts.expected │ │ ├── field_definitions │ │ │ ├── DeprecatedMethodField.ts │ │ │ ├── DeprecatedMethodField.ts.expected │ │ │ ├── DeprecatedPropertyField.ts │ │ │ ├── DeprecatedPropertyField.ts.expected │ │ │ ├── FieldAsSetter.invalid.ts │ │ │ ├── FieldAsSetter.invalid.ts.expected │ │ │ ├── FieldAsStaticClassMethod.ts │ │ │ ├── FieldAsStaticClassMethod.ts.expected │ │ │ ├── FieldAsStaticClassMethodInNestedScope.invalid.ts │ │ │ ├── FieldAsStaticClassMethodInNestedScope.invalid.ts.expected │ │ │ ├── FieldAsStaticClassMethodInNestedScopeButExported.invalid.ts │ │ │ ├── FieldAsStaticClassMethodInNestedScopeButExported.invalid.ts.expected │ │ │ ├── FieldAsStaticClassMethodNotExported.invalid.ts │ │ │ ├── FieldAsStaticClassMethodNotExported.invalid.ts.expected │ │ │ ├── FieldAsStaticClassMethodOnNonDefaultExportUnnamedNonGqlClass.ts │ │ │ ├── FieldAsStaticClassMethodOnNonDefaultExportUnnamedNonGqlClass.ts.expected │ │ │ ├── FieldAsStaticClassMethodOnNonGqlClass.ts │ │ │ ├── FieldAsStaticClassMethodOnNonGqlClass.ts.expected │ │ │ ├── FieldAsStaticClassMethodOnUnnamedNonGqlClass.ts │ │ │ ├── FieldAsStaticClassMethodOnUnnamedNonGqlClass.ts.expected │ │ │ ├── FieldAsStaticClassMethodWithClassAsDefaultExport.ts │ │ │ ├── FieldAsStaticClassMethodWithClassAsDefaultExport.ts.expected │ │ │ ├── FieldAsStaticMethodOnInterface.invalid.ts │ │ │ ├── FieldAsStaticMethodOnInterface.invalid.ts.expected │ │ │ ├── FieldDefinedOnNonGqlType.ts │ │ │ ├── FieldDefinedOnNonGqlType.ts.expected │ │ │ ├── FieldOnArbitraryParam.ts │ │ │ ├── FieldOnArbitraryParam.ts.expected │ │ │ ├── FieldTagOnIncorrectNode.ts │ │ │ ├── FieldTagOnIncorrectNode.ts.expected │ │ │ ├── FiledWithUnionOfMultipleTypes.ts │ │ │ ├── FiledWithUnionOfMultipleTypes.ts.expected │ │ │ ├── GetAcessorField.ts │ │ │ ├── GetAcessorField.ts.expected │ │ │ ├── MethodFieldMissingType.invalid.ts │ │ │ ├── MethodFieldMissingType.invalid.ts.expected │ │ │ ├── MethodSignatureOnInterface.ts │ │ │ ├── MethodSignatureOnInterface.ts.expected │ │ │ ├── MultipleFieldsAsStaticClassMethods.ts │ │ │ ├── MultipleFieldsAsStaticClassMethods.ts.expected │ │ │ ├── ParameterPropertyField.ts │ │ │ ├── ParameterPropertyField.ts.expected │ │ │ ├── ParameterPropertyFieldBindingPattern.invalid.ts │ │ │ ├── ParameterPropertyFieldBindingPattern.invalid.ts.expected │ │ │ ├── ParameterPropertyFieldDeprecated.ts │ │ │ ├── ParameterPropertyFieldDeprecated.ts.expected │ │ │ ├── ParameterPropertyFieldNoModifier.invalid.ts │ │ │ ├── ParameterPropertyFieldNoModifier.invalid.ts.expected │ │ │ ├── ParameterPropertyFieldNoType.invalid.ts │ │ │ ├── ParameterPropertyFieldNoType.invalid.ts.expected │ │ │ ├── ParameterPropertyFieldReadOnly.ts │ │ │ ├── ParameterPropertyFieldReadOnly.ts.expected │ │ │ ├── ParameterPropertyFieldReadOnlyPrivate.invalid.ts │ │ │ ├── ParameterPropertyFieldReadOnlyPrivate.invalid.ts.expected │ │ │ ├── ParameterPropertyFieldRenamed.ts │ │ │ ├── ParameterPropertyFieldRenamed.ts.expected │ │ │ ├── ParameterPropertyFieldWithDescription.ts │ │ │ ├── ParameterPropertyFieldWithDescription.ts.expected │ │ │ ├── PrivateAndProtectedFieldMethods.invalid.ts │ │ │ ├── PrivateAndProtectedFieldMethods.invalid.ts.expected │ │ │ ├── PropertyFieldMissingType.invalid.ts │ │ │ ├── PropertyFieldMissingType.invalid.ts.expected │ │ │ ├── PublicFieldMethod.ts │ │ │ ├── PublicFieldMethod.ts.expected │ │ │ ├── ReferenceNonGraphQLType.ts │ │ │ ├── ReferenceNonGraphQLType.ts.expected │ │ │ ├── ReferenceUndefinedType.ts │ │ │ ├── ReferenceUndefinedType.ts.expected │ │ │ ├── RenamedField.ts │ │ │ ├── RenamedField.ts.expected │ │ │ ├── RenamedFieldWithArgs.ts │ │ │ ├── RenamedFieldWithArgs.ts.expected │ │ │ ├── RenamedFieldWithDescription.ts │ │ │ ├── RenamedFieldWithDescription.ts.expected │ │ │ ├── StringFieldWithDescription.ts │ │ │ ├── StringFieldWithDescription.ts.expected │ │ │ ├── asyncFunctionFieldNotExported.invalid.ts │ │ │ └── asyncFunctionFieldNotExported.invalid.ts.expected │ │ ├── field_values │ │ │ ├── ArrayField.ts │ │ │ ├── ArrayField.ts.expected │ │ │ ├── ArrayOfPromises.ts │ │ │ ├── ArrayOfPromises.ts.expected │ │ │ ├── ArrayShorthandField.ts │ │ │ ├── ArrayShorthandField.ts.expected │ │ │ ├── ArrayWithNullableItems.ts │ │ │ ├── ArrayWithNullableItems.ts.expected │ │ │ ├── AsyncPromiseField.ts │ │ │ ├── AsyncPromiseField.ts.expected │ │ │ ├── BooleanField.ts │ │ │ ├── BooleanField.ts.expected │ │ │ ├── CustomScalar.ts │ │ │ ├── CustomScalar.ts.expected │ │ │ ├── DuplicateFields.ts │ │ │ ├── DuplicateFields.ts.expected │ │ │ ├── KillsParentOnExceptionDoesNotMatchInterface.invalid.ts │ │ │ ├── KillsParentOnExceptionDoesNotMatchInterface.invalid.ts.expected │ │ │ ├── KitchenSink.ts │ │ │ ├── KitchenSink.ts.expected │ │ │ ├── LinkedField.ts │ │ │ ├── LinkedField.ts.expected │ │ │ ├── LinkedFieldWithTypeArg.ts │ │ │ ├── LinkedFieldWithTypeArg.ts.expected │ │ │ ├── MaybePromise.ts │ │ │ ├── MaybePromise.ts.expected │ │ │ ├── OptionalFields.ts │ │ │ ├── OptionalFields.ts.expected │ │ │ ├── OptionalProperty.ts │ │ │ ├── OptionalProperty.ts.expected │ │ │ ├── OptionalStringFieldKillsParentOnException.invalid.ts │ │ │ ├── OptionalStringFieldKillsParentOnException.invalid.ts.expected │ │ │ ├── ParenthesizedType.ts │ │ │ ├── ParenthesizedType.ts.expected │ │ │ ├── PromiseOfPromise.ts │ │ │ ├── PromiseOfPromise.ts.expected │ │ │ ├── ReadonlyArrayField.ts │ │ │ ├── ReadonlyArrayField.ts.expected │ │ │ ├── RenamedType.ts │ │ │ ├── RenamedType.ts.expected │ │ │ ├── RenamedTypeOutOfOrder.ts │ │ │ ├── RenamedTypeOutOfOrder.ts.expected │ │ │ ├── StringField.ts │ │ │ ├── StringField.ts.expected │ │ │ ├── StringFieldKillsParentOnException.ts │ │ │ ├── StringFieldKillsParentOnException.ts.expected │ │ │ ├── StringFieldKillsParentOnExceptionWithoutNullableByDefaultEnables.invalid.ts │ │ │ ├── StringFieldKillsParentOnExceptionWithoutNullableByDefaultEnables.invalid.ts.expected │ │ │ ├── UnionField.ts │ │ │ ├── UnionField.ts.expected │ │ │ └── non_default_nullable │ │ │ │ ├── NonNullablePromise.ts │ │ │ │ ├── NonNullablePromise.ts.expected │ │ │ │ ├── NullablePromise.ts │ │ │ │ └── NullablePromise.ts.expected │ │ ├── generics │ │ │ ├── arrayPassedToGeneric.invalid.ts │ │ │ ├── arrayPassedToGeneric.invalid.ts.expected │ │ │ ├── complexMutualReferences.ts │ │ │ ├── complexMutualReferences.ts.expected │ │ │ ├── connection.ts │ │ │ ├── connection.ts.expected │ │ │ ├── connectionEdgeAsGeneric.ts │ │ │ ├── connectionEdgeAsGeneric.ts.expected │ │ │ ├── defineFieldOnGeneric.ts │ │ │ ├── defineFieldOnGeneric.ts.expected │ │ │ ├── edge.ts │ │ │ ├── edge.ts.expected │ │ │ ├── enumWithGeneric.invalid.ts │ │ │ ├── enumWithGeneric.invalid.ts.expected │ │ │ ├── genericInputType.ts │ │ │ ├── genericInputType.ts.expected │ │ │ ├── genericInterface.ts │ │ │ ├── genericInterface.ts.expected │ │ │ ├── genericOverArg.ts │ │ │ ├── genericOverArg.ts.expected │ │ │ ├── genericReferencedMoreThanOnce.ts │ │ │ ├── genericReferencedMoreThanOnce.ts.expected │ │ │ ├── genericTypeUsedAsUnionMember.invalid.ts │ │ │ ├── genericTypeUsedAsUnionMember.invalid.ts.expected │ │ │ ├── genericTypeUsedAsUnionMemberViaTypeParam.invalid.ts │ │ │ ├── genericTypeUsedAsUnionMemberViaTypeParam.invalid.ts.expected │ │ │ ├── genericTypeUsingClass.ts │ │ │ ├── genericTypeUsingClass.ts.expected │ │ │ ├── genericTypeUsingInterface.ts │ │ │ ├── genericTypeUsingInterface.ts.expected │ │ │ ├── missingGqlGenericTypeArg.ts │ │ │ ├── missingGqlGenericTypeArg.ts.expected │ │ │ ├── multiparamGeneric.ts │ │ │ ├── multiparamGeneric.ts.expected │ │ │ ├── passOuptutTypeToInputType.input.ts │ │ │ ├── passOuptutTypeToInputType.input.ts.expected │ │ │ ├── referencingMethodGeneric.invalid.ts │ │ │ ├── referencingMethodGeneric.invalid.ts.expected │ │ │ ├── result.ts │ │ │ ├── result.ts.expected │ │ │ ├── scalarPassedAsGenericArg.ts │ │ │ ├── scalarPassedAsGenericArg.ts.expected │ │ │ ├── scalarPassedAsNonGqlGenericArg.ts │ │ │ ├── scalarPassedAsNonGqlGenericArg.ts.expected │ │ │ ├── scalarWithGeneric.ts │ │ │ ├── scalarWithGeneric.ts.expected │ │ │ ├── todo │ │ │ │ ├── genericInterfaceFromTypeParam.ts │ │ │ │ ├── genericInterfaceFromTypeParam.ts.expected │ │ │ │ ├── genericTypeImplementsInterface.ts │ │ │ │ ├── genericTypeImplementsInterface.ts.expected │ │ │ │ ├── genericTypeMemberOfUnion.ts │ │ │ │ └── genericTypeMemberOfUnion.ts.expected │ │ │ ├── undefinedTypeUsedAsGenericTypeArg.ts │ │ │ └── undefinedTypeUsedAsGenericTypeArg.ts.expected │ │ ├── headers │ │ │ ├── customHeaders.ts │ │ │ ├── customHeaders.ts.expected │ │ │ ├── multilineHeader.ts │ │ │ └── multilineHeader.ts.expected │ │ ├── input_type_one_of │ │ │ ├── oneOfDeprecated.invalid.ts │ │ │ ├── oneOfDeprecated.invalid.ts.expected │ │ │ ├── oneOfFieldIsNullable.ts │ │ │ ├── oneOfFieldIsNullable.ts.expected │ │ │ ├── oneOfFieldIsOptional.ts │ │ │ ├── oneOfFieldIsOptional.ts.expected │ │ │ ├── oneOfFieldMissingTypeAnnotation.invalid.ts │ │ │ ├── oneOfFieldMissingTypeAnnotation.invalid.ts.expected │ │ │ ├── oneOfFieldTypeList.ts │ │ │ ├── oneOfFieldTypeList.ts.expected │ │ │ ├── oneOfFieldTypeListOfNullable.ts │ │ │ ├── oneOfFieldTypeListOfNullable.ts.expected │ │ │ ├── oneOfFieldTypeNotGraphQL.invalid.ts │ │ │ ├── oneOfFieldTypeNotGraphQL.invalid.ts.expected │ │ │ ├── oneOfMemberHasMultipleFields.invalid.ts │ │ │ ├── oneOfMemberHasMultipleFields.invalid.ts.expected │ │ │ ├── oneOfMemberHasNoField.invalid.ts │ │ │ ├── oneOfMemberHasNoField.invalid.ts.expected │ │ │ ├── oneOfUnionMemberNotLiteral.ts │ │ │ ├── oneOfUnionMemberNotLiteral.ts.expected │ │ │ ├── oneOfWithFieldDescription.ts │ │ │ ├── oneOfWithFieldDescription.ts.expected │ │ │ ├── oneOfWithFieldDescriptionInsideObj.ts │ │ │ ├── oneOfWithFieldDescriptionInsideObj.ts.expected │ │ │ ├── oneOfWithTypeDescription.ts │ │ │ ├── oneOfWithTypeDescription.ts.expected │ │ │ ├── simpleOneOf.ts │ │ │ ├── simpleOneOf.ts.expected │ │ │ ├── simpleOneOfDeprecatedTag.invalid.ts │ │ │ └── simpleOneOfDeprecatedTag.invalid.ts.expected │ │ ├── input_types │ │ │ ├── ContextReferencedInInputType.invalid.ts │ │ │ ├── ContextReferencedInInputType.invalid.ts.expected │ │ │ ├── DeprecatedInputType.invalid.ts │ │ │ ├── DeprecatedInputType.invalid.ts.expected │ │ │ ├── InputType.ts │ │ │ ├── InputType.ts.expected │ │ │ ├── InputTypeInterface.ts │ │ │ ├── InputTypeInterface.ts.expected │ │ │ ├── InputTypeInterfaceFunction.ts │ │ │ ├── InputTypeInterfaceFunction.ts.expected │ │ │ ├── InputTypeInterfaceMethod.invalid.ts │ │ │ ├── InputTypeInterfaceMethod.invalid.ts.expected │ │ │ ├── InputTypeInterfaceOptionalField.ts │ │ │ ├── InputTypeInterfaceOptionalField.ts.expected │ │ │ ├── InputTypeInterfacePromiseField.invalid.ts │ │ │ ├── InputTypeInterfacePromiseField.invalid.ts.expected │ │ │ ├── InputTypeMergedInterface.invalid.ts │ │ │ ├── InputTypeMergedInterface.invalid.ts.expected │ │ │ ├── InputTypeOptionalField.ts │ │ │ ├── InputTypeOptionalField.ts.expected │ │ │ ├── InputTypeReferencingOutputType.invalid.ts │ │ │ ├── InputTypeReferencingOutputType.invalid.ts.expected │ │ │ ├── InputTypeReturnedFromField.invalid.ts │ │ │ ├── InputTypeReturnedFromField.invalid.ts.expected │ │ │ ├── InputTypeWithDeprecatedField.ts │ │ │ ├── InputTypeWithDeprecatedField.ts.expected │ │ │ ├── InputTypeWithDeprecatedRequiredField.invalid.ts │ │ │ ├── InputTypeWithDeprecatedRequiredField.invalid.ts.expected │ │ │ ├── InputTypeWithDescription.ts │ │ │ ├── InputTypeWithDescription.ts.expected │ │ │ ├── InputTypeWithFieldDescription.ts │ │ │ ├── InputTypeWithFieldDescription.ts.expected │ │ │ ├── RenamedInputType.ts │ │ │ ├── RenamedInputType.ts.expected │ │ │ ├── inputFieldWithGqlField.invalid.ts │ │ │ └── inputFieldWithGqlField.invalid.ts.expected │ │ ├── interfaces │ │ │ ├── FieldReturnsInterface.ts │ │ │ ├── FieldReturnsInterface.ts.expected │ │ │ ├── IgnoresExtendsClause.ts │ │ │ ├── IgnoresExtendsClause.ts.expected │ │ │ ├── ImplementsInterface.ts │ │ │ ├── ImplementsInterface.ts.expected │ │ │ ├── ImplementsInterfaceWithTypeParam.ts │ │ │ ├── ImplementsInterfaceWithTypeParam.ts.expected │ │ │ ├── ImplementsMultipleInterfaces.ts │ │ │ ├── ImplementsMultipleInterfaces.ts.expected │ │ │ ├── ImplementsRenamedInterface.ts │ │ │ ├── ImplementsRenamedInterface.ts.expected │ │ │ ├── InterfaceDefinitionExtendsGqlInterface.ts │ │ │ ├── InterfaceDefinitionExtendsGqlInterface.ts.expected │ │ │ ├── InterfaceExtendsInterface.ts │ │ │ ├── InterfaceExtendsInterface.ts.expected │ │ │ ├── InterfaceFieldWithDescription.ts │ │ │ ├── InterfaceFieldWithDescription.ts.expected │ │ │ ├── InterfaceFieldWithDescriptionThatDiffersFromType.ts │ │ │ ├── InterfaceFieldWithDescriptionThatDiffersFromType.ts.expected │ │ │ ├── InterfaceImplementsInterface.ts │ │ │ ├── InterfaceImplementsInterface.ts.expected │ │ │ ├── InterfaceMergedIntoClass.invalid.ts │ │ │ ├── InterfaceMergedIntoClass.invalid.ts.expected │ │ │ ├── InterfaceMergedIntoNode.invalid.ts │ │ │ ├── InterfaceMergedIntoNode.invalid.ts.expected │ │ │ ├── InterfaceMergedIntoObject.invalid.ts │ │ │ ├── InterfaceMergedIntoObject.invalid.ts.expected │ │ │ ├── InterfaceMissingFields.invalid.ts │ │ │ ├── InterfaceMissingFields.invalid.ts.expected │ │ │ ├── InterfaceWithCustomName.ts │ │ │ ├── InterfaceWithCustomName.ts.expected │ │ │ ├── InterfaceWithDeprecatedField.ts │ │ │ ├── InterfaceWithDeprecatedField.ts.expected │ │ │ ├── InterfaceWithDescription.ts │ │ │ ├── InterfaceWithDescription.ts.expected │ │ │ ├── MergedInterfaces.ts │ │ │ ├── MergedInterfaces.ts.expected │ │ │ ├── TagAttachedToWrongNode.ts │ │ │ ├── TagAttachedToWrongNode.ts.expected │ │ │ ├── extendInterfaceWithNonGqlType.ts │ │ │ ├── extendInterfaceWithNonGqlType.ts.expected │ │ │ └── tag │ │ │ │ ├── ImplementsTagWithoutTypeOrInterface.invalid.ts │ │ │ │ └── ImplementsTagWithoutTypeOrInterface.invalid.ts.expected │ │ ├── locate │ │ │ ├── fieldOnScalar.invalid.ts │ │ │ ├── fieldOnScalar.invalid.ts.expected │ │ │ ├── genericType.ts │ │ │ ├── genericType.ts.expected │ │ │ ├── genericTypeField.ts │ │ │ ├── genericTypeField.ts.expected │ │ │ ├── inputType.ts │ │ │ ├── inputType.ts.expected │ │ │ ├── inputTypeField.ts │ │ │ ├── inputTypeField.ts.expected │ │ │ ├── interface.ts │ │ │ ├── interface.ts.expected │ │ │ ├── malformedEntitySyntax.invalid.ts │ │ │ ├── malformedEntitySyntax.invalid.ts.expected │ │ │ ├── notFoundField.invalid.ts │ │ │ ├── notFoundField.invalid.ts.expected │ │ │ ├── notFoundType.invalid.ts │ │ │ ├── notFoundType.invalid.ts.expected │ │ │ ├── type.ts │ │ │ ├── type.ts.expected │ │ │ ├── typeField.ts │ │ │ └── typeField.ts.expected │ │ ├── regression │ │ │ ├── fieldFollowedByDeprecated.ts │ │ │ └── fieldFollowedByDeprecated.ts.expected │ │ ├── resolver_context │ │ │ ├── ClassMethodWithContextValue.ts │ │ │ ├── ClassMethodWithContextValue.ts.expected │ │ │ ├── ClassMethodWithContextValueExported.ts │ │ │ ├── ClassMethodWithContextValueExported.ts.expected │ │ │ ├── ClassMethodWithContextValueInArgsPos.invalid.ts │ │ │ ├── ClassMethodWithContextValueInArgsPos.invalid.ts.expected │ │ │ ├── ContextValueBeforeArgs.ts │ │ │ ├── ContextValueBeforeArgs.ts.expected │ │ │ ├── ContextValueMissingTypeAnnotation.invalid.ts │ │ │ ├── ContextValueMissingTypeAnnotation.invalid.ts.expected │ │ │ ├── ContextValueOptional.ts │ │ │ ├── ContextValueOptional.ts.expected │ │ │ ├── ContextValueReadTwice.ts │ │ │ ├── ContextValueReadTwice.ts.expected │ │ │ ├── ContextValueSpread.invalid.ts │ │ │ ├── ContextValueSpread.invalid.ts.expected │ │ │ ├── ContextValueTypeNotDefined.ts │ │ │ ├── ContextValueTypeNotDefined.ts.expected │ │ │ ├── ContextValueTypedAsAny.invalid.ts │ │ │ ├── ContextValueTypedAsAny.invalid.ts.expected │ │ │ ├── ContextValueTypedAsNever.invalid.ts │ │ │ ├── ContextValueTypedAsNever.invalid.ts.expected │ │ │ ├── ContextValueTypedAsUnknown.invalid.ts │ │ │ ├── ContextValueTypedAsUnknown.invalid.ts.expected │ │ │ ├── FunctionWithContextValue.ts │ │ │ ├── FunctionWithContextValue.ts.expected │ │ │ ├── MultipleClassMethodsReferencingContextValue.ts │ │ │ ├── MultipleClassMethodsReferencingContextValue.ts.expected │ │ │ ├── MultipleContextValuesUsed.invalid.ts │ │ │ └── MultipleContextValuesUsed.invalid.ts.expected │ │ ├── resolver_info │ │ │ ├── ClassMethodWithInfoValue.ts │ │ │ ├── ClassMethodWithInfoValue.ts.expected │ │ │ ├── FunctionWithInfoValue.ts │ │ │ ├── FunctionWithInfoValue.ts.expected │ │ │ ├── StaticMethodWithInfoValue.ts │ │ │ └── StaticMethodWithInfoValue.ts.expected │ │ ├── semantic_nullability │ │ │ ├── nonNullDoesNotMatchInterface.invalid.ts │ │ │ ├── nonNullDoesNotMatchInterface.invalid.ts.expected │ │ │ ├── semanticNonNull.ts │ │ │ ├── semanticNonNull.ts.expected │ │ │ ├── semanticNonNullDoesNotMatchInterface.invalid.ts │ │ │ ├── semanticNonNullDoesNotMatchInterface.invalid.ts.expected │ │ │ ├── semanticNonNullMatchesInterface.ts │ │ │ ├── semanticNonNullMatchesInterface.ts.expected │ │ │ ├── semanticNull.ts │ │ │ └── semanticNull.ts.expected │ │ ├── subscriptions │ │ │ ├── InputTypeWithAsyncIterable.invalid.ts │ │ │ ├── InputTypeWithAsyncIterable.invalid.ts.expected │ │ │ ├── InterfaceWithAsyncIterable.ts │ │ │ ├── InterfaceWithAsyncIterable.ts.expected │ │ │ ├── NonSubscriptionClassWithAsyncIterable.ts │ │ │ ├── NonSubscriptionClassWithAsyncIterable.ts.expected │ │ │ ├── SubscriptionClassWithAsyncIterable.invalid.ts │ │ │ ├── SubscriptionClassWithAsyncIterable.invalid.ts.expected │ │ │ ├── SubscriptionFunctionFieldWithAsyncIterable.ts │ │ │ └── SubscriptionFunctionFieldWithAsyncIterable.ts.expected │ │ ├── todo │ │ │ ├── EnumFromUnionTypeWithVariantWithDescription.ts │ │ │ ├── EnumFromUnionTypeWithVariantWithDescription.ts.expected │ │ │ ├── RedefineBuiltinScalar.invalid.ts │ │ │ ├── RedefineBuiltinScalar.invalid.ts.expected │ │ │ ├── userExample.ts │ │ │ └── userExample.ts.expected │ │ ├── top_level_fields │ │ │ ├── queryField.ts │ │ │ ├── queryField.ts.expected │ │ │ ├── queryFieldOnMethod.ts │ │ │ ├── queryFieldOnMethod.ts.expected │ │ │ ├── queryFieldOnStaticMethod.ts │ │ │ ├── queryFieldOnStaticMethod.ts.expected │ │ │ ├── queryFieldRenamed.ts │ │ │ ├── queryFieldRenamed.ts.expected │ │ │ ├── queryFieldWithExplicitlyDefinedQuery.ts │ │ │ ├── queryFieldWithExplicitlyDefinedQuery.ts.expected │ │ │ ├── queryFieldWithFirstArgParentType.invalid.ts │ │ │ ├── queryFieldWithFirstArgParentType.invalid.ts.expected │ │ │ ├── rootFields.ts │ │ │ ├── rootFields.ts.expected │ │ │ ├── rootSubscriptionFieldNotAsyncIterable.invalid.ts │ │ │ └── rootSubscriptionFieldNotAsyncIterable.invalid.ts.expected │ │ ├── type_definitions │ │ │ ├── ClassImplementsNonGqlInterface.ts │ │ │ ├── ClassImplementsNonGqlInterface.ts.expected │ │ │ ├── ClassMissingFields.invalid.ts │ │ │ ├── ClassMissingFields.invalid.ts.expected │ │ │ ├── ClassWithDescription.ts │ │ │ ├── ClassWithDescription.ts.expected │ │ │ ├── ClassWithDescriptionAndCustomName.ts │ │ │ ├── ClassWithDescriptionAndCustomName.ts.expected │ │ │ ├── ClassWithoutAName.invalid.ts │ │ │ ├── ClassWithoutAName.invalid.ts.expected │ │ │ ├── QueryAsClass.invalid.ts │ │ │ ├── QueryAsClass.invalid.ts.expected │ │ │ ├── RenamedType.ts │ │ │ ├── RenamedType.ts.expected │ │ │ ├── RenamedTypeHasDash.invalid.ts │ │ │ ├── RenamedTypeHasDash.invalid.ts.expected │ │ │ ├── RenamedTypeNewLine.invalid.ts │ │ │ ├── RenamedTypeNewLine.invalid.ts.expected │ │ │ ├── RenamedTypeStartsWithNumber.invalid.ts │ │ │ ├── RenamedTypeStartsWithNumber.invalid.ts.expected │ │ │ ├── RenamedTypeWithoutClassName.invalid.ts │ │ │ ├── RenamedTypeWithoutClassName.invalid.ts.expected │ │ │ ├── TagAttachedToWrongNode.ts │ │ │ ├── TagAttachedToWrongNode.ts.expected │ │ │ ├── TypeFromClassDefinitionImplementsInterface.ts │ │ │ ├── TypeFromClassDefinitionImplementsInterface.ts.expected │ │ │ ├── TypeFromClassDefinitionImplementsInterfaceWithDeprecatedTag.invalid.ts │ │ │ ├── TypeFromClassDefinitionImplementsInterfaceWithDeprecatedTag.invalid.ts.expected │ │ │ ├── TypeFromClassDefinitionImplementsMultipleInterfaces.ts │ │ │ └── TypeFromClassDefinitionImplementsMultipleInterfaces.ts.expected │ │ ├── type_definitions_from_alias │ │ │ ├── AliasIsArrayNotLiteral.invalid.ts │ │ │ ├── AliasIsArrayNotLiteral.invalid.ts.expected │ │ │ ├── AliasIsNumberNotLiteral.invalid.ts │ │ │ ├── AliasIsNumberNotLiteral.invalid.ts.expected │ │ │ ├── AliasOfUnknownDefinesType.ts │ │ │ ├── AliasOfUnknownDefinesType.ts.expected │ │ │ ├── AliasType.ts │ │ │ ├── AliasType.ts.expected │ │ │ ├── AliasTypeImplementsInterface.invalid.ts │ │ │ ├── AliasTypeImplementsInterface.invalid.ts.expected │ │ │ ├── AliasWithDescription.ts │ │ │ ├── AliasWithDescription.ts.expected │ │ │ ├── AliasWithDescriptionAndCustomName.ts │ │ │ ├── AliasWithDescriptionAndCustomName.ts.expected │ │ │ ├── QueryAsAliasOfObject.invalid.ts │ │ │ ├── QueryAsAliasOfObject.invalid.ts.expected │ │ │ ├── QueryAsAliasOfUndefined.invalid.ts │ │ │ ├── QueryAsAliasOfUndefined.invalid.ts.expected │ │ │ ├── QueryAsAliasOfUnknown.ts │ │ │ ├── QueryAsAliasOfUnknown.ts.expected │ │ │ ├── RenamedType.ts │ │ │ └── RenamedType.ts.expected │ │ ├── type_definitions_from_interface │ │ │ ├── InterfaceType.ts │ │ │ ├── InterfaceType.ts.expected │ │ │ ├── InterfaceTypeExtendsGqlInterface.ts │ │ │ ├── InterfaceTypeExtendsGqlInterface.ts.expected │ │ │ ├── InterfaceTypeExtendsGqlInterfaceWithDeprecatedTag.invalid.ts │ │ │ ├── InterfaceTypeExtendsGqlInterfaceWithDeprecatedTag.invalid.ts.expected │ │ │ ├── InterfaceTypeImplementsInterface.ts │ │ │ ├── InterfaceTypeImplementsInterface.ts.expected │ │ │ ├── InterfaceWithDescription.ts │ │ │ ├── InterfaceWithDescription.ts.expected │ │ │ ├── InterfaceWithDescriptionAndCustomName.ts │ │ │ ├── InterfaceWithDescriptionAndCustomName.ts.expected │ │ │ ├── QueryFromInterface.invlaid.ts │ │ │ ├── QueryFromInterface.invlaid.ts.expected │ │ │ ├── RenamedType.ts │ │ │ ├── RenamedType.ts.expected │ │ │ ├── TagAttachedToWrongNode.ts │ │ │ └── TagAttachedToWrongNode.ts.expected │ │ ├── typename │ │ │ ├── ImplementorMissingTypename.ts │ │ │ ├── ImplementorMissingTypename.ts.expected │ │ │ ├── MethodTypename.ts │ │ │ ├── MethodTypename.ts.expected │ │ │ ├── PropertySignatureTypename.ts │ │ │ ├── PropertySignatureTypename.ts.expected │ │ │ ├── PropertySignatureTypenameIncorrectName.ts │ │ │ ├── PropertySignatureTypenameIncorrectName.ts.expected │ │ │ ├── PropertySignatureTypenameMissingType.ts │ │ │ ├── PropertySignatureTypenameMissingType.ts.expected │ │ │ ├── PropertySignatureTypenameNonLiteralType.ts │ │ │ ├── PropertySignatureTypenameNonLiteralType.ts.expected │ │ │ ├── PropertyTypename.ts │ │ │ ├── PropertyTypename.ts.expected │ │ │ ├── PropertyTypenameDoesNotMatchClassName.ts │ │ │ ├── PropertyTypenameDoesNotMatchClassName.ts.expected │ │ │ ├── PropertyTypenameDoesNotMatchDeclaredName.ts │ │ │ ├── PropertyTypenameDoesNotMatchDeclaredName.ts.expected │ │ │ ├── PropertyTypenameMustNeedToBeDeclaredAsConst.ts │ │ │ ├── PropertyTypenameMustNeedToBeDeclaredAsConst.ts.expected │ │ │ ├── PropertyTypenameMustNeedToBeDeclaredAsExactlyConst.ts │ │ │ ├── PropertyTypenameMustNeedToBeDeclaredAsExactlyConst.ts.expected │ │ │ ├── PropertyTypenameNoInitializer.ts │ │ │ ├── PropertyTypenameNoInitializer.ts.expected │ │ │ ├── PropertyTypenameNonStringInitializer.ts │ │ │ ├── PropertyTypenameNonStringInitializer.ts.expected │ │ │ ├── UnionMemberMissingTypename.ts │ │ │ └── UnionMemberMissingTypename.ts.expected │ │ ├── unions │ │ │ ├── DefineUnionOfOneType.ts │ │ │ ├── DefineUnionOfOneType.ts.expected │ │ │ ├── DefineUnionType.ts │ │ │ ├── DefineUnionType.ts.expected │ │ │ ├── DefineUnionTypeContainingInterface.invalid.ts │ │ │ ├── DefineUnionTypeContainingInterface.invalid.ts.expected │ │ │ ├── DefineUnionTypeReferencingInputType.invalid.ts │ │ │ ├── DefineUnionTypeReferencingInputType.invalid.ts.expected │ │ │ ├── DefineUnionTypeReferencingLiteral.invalid.ts │ │ │ ├── DefineUnionTypeReferencingLiteral.invalid.ts.expected │ │ │ ├── DefineUnionTypeWithInterfaces.ts │ │ │ ├── DefineUnionTypeWithInterfaces.ts.expected │ │ │ ├── DefineUnionTypeWithTypeLiterals.ts │ │ │ ├── DefineUnionTypeWithTypeLiterals.ts.expected │ │ │ ├── UnionAsMemberOfItself.invalid.ts │ │ │ ├── UnionAsMemberOfItself.invalid.ts.expected │ │ │ ├── UnionAsMemberOfOtherUnion.invalid.ts │ │ │ ├── UnionAsMemberOfOtherUnion.invalid.ts.expected │ │ │ ├── UnionWithDescription.ts │ │ │ └── UnionWithDescription.ts.expected │ │ └── user_error │ │ │ ├── GqlTagDoesNotExist.ts │ │ │ ├── GqlTagDoesNotExist.ts.expected │ │ │ ├── InvalidSyntax.invalid.ts │ │ │ ├── InvalidSyntax.invalid.ts.expected │ │ │ ├── KillsParentOnExceptionOnNonField.invalid.ts │ │ │ ├── KillsParentOnExceptionOnNonField.invalid.ts.expected │ │ │ ├── TypeErrorWithTypeCheckingEnabled.ts │ │ │ ├── TypeErrorWithTypeCheckingEnabled.ts.expected │ │ │ ├── WrongCaseGqlTag.ts │ │ │ └── WrongCaseGqlTag.ts.expected │ ├── integration.mjs │ ├── integrationFixtures │ │ ├── aliasedMethod │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── complexDefaultInput │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── complexPlurals │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── connectionExample │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── deprecated │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── derivedContext │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── enumDefault │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── explicitNullPassedToArgWithDefault │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── functionField │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── functionFieldRenamed │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── getAcessor │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── inputTypeOneOf │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── killsParentOnException │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── killsParentOnExceptionOnQuery │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── killsParentOnExceptionReturnsNull │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── nonNullArgWithDefault │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── nonNullEnumDefault │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── nonNullableListIncludesNull │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── numericID │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── parameterPropertyRenamed │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── positionalNonNullArgWithDefault │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── promiseOfPromise │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── resolveTypeViaClass │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ ├── resolverErrorElidedToNull │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ │ └── strictSemanticNullability │ │ │ ├── index.ts │ │ │ ├── index.ts.expected │ │ │ └── schema.ts │ ├── test.ts │ └── yesNo.ts ├── transforms │ ├── addImplicitRootTypes.ts │ ├── addInterfaceFields.ts │ ├── applyDefaultNullability.ts │ ├── coerceDefaultEnumValues.ts │ ├── filterNonGqlInterfaces.ts │ ├── makeResolverSignature.ts │ ├── mergeExtensions.ts │ ├── resolveResolverParams.ts │ ├── resolveTypes.ts │ ├── snapshotsFromProgram.ts │ └── sortSchemaAst.ts ├── tsPlugin │ └── initTsPlugin.ts ├── utils │ ├── DiagnosticError.ts │ ├── JSDoc.ts │ ├── Result.ts │ ├── helpers.ts │ └── naturalCompare.ts └── validations │ ├── customSpecValidations.ts │ ├── validateAsyncIterable.ts │ ├── validateDirectiveArguments.ts │ ├── validateDuplicateContextOrInfo.ts │ ├── validateMergedInterfaces.ts │ ├── validateSemanticNullability.ts │ └── validateTypenames.ts ├── tsconfig.json └── website ├── .gitignore ├── README.md ├── babel.config.js ├── docs ├── 01-getting-started │ ├── 01-quick-start.mdx │ ├── 02-cli.md │ ├── 03-configuration.md │ ├── 04-comment-syntax.md │ ├── _category_.json │ └── index.mdx ├── 03-resolvers │ ├── 03-descriptions.mdx │ ├── 04-renaming.mdx │ ├── 05-deprecated.mdx │ ├── 06-nullability.mdx │ ├── 07-generics.md │ ├── _category_.json │ ├── index.mdx │ └── snippets │ │ ├── 02-resolver-signature-function.grats.ts │ │ ├── 02-resolver-signature-function.out │ │ ├── 02-resolver-signature-method.grats.ts │ │ ├── 02-resolver-signature-method.out │ │ ├── 03-description-enum-fail.grats.ts │ │ ├── 03-description-enum-fail.out │ │ ├── 03-description-example.grats.ts │ │ ├── 03-description-example.out │ │ ├── 04-renaming-field.grats.ts │ │ ├── 04-renaming-field.out │ │ ├── 04-renaming-type.grats.ts │ │ ├── 04-renaming-type.out │ │ ├── 05-deprecated-example.grats.ts │ │ ├── 05-deprecated-example.out │ │ ├── 06-nullability.grats.ts │ │ ├── 06-nullability.out │ │ ├── deprecated-workaround.grats.ts │ │ └── deprecated-workaround.out ├── 04-docblock-tags │ ├── 01-types.mdx │ ├── 02-fields.mdx │ ├── 02-root-fields.mdx │ ├── 03-arguments.mdx │ ├── 04-context.mdx │ ├── 04-info.mdx │ ├── 05-interfaces.mdx │ ├── 06-unions.mdx │ ├── 07-enums.mdx │ ├── 08-scalars.mdx │ ├── 09-inputs.mdx │ ├── 10-oneof-inputs.mdx │ ├── 11-directive-definitions.mdx │ ├── 12-directive-annotations.mdx │ ├── _category_.json │ ├── index.md │ └── snippets │ │ ├── 01-root-type-with-description.grats.ts │ │ ├── 01-root-type-with-description.out │ │ ├── 01-types-alias.grats.ts │ │ ├── 01-types-alias.out │ │ ├── 01-types-class.grats.ts │ │ ├── 01-types-class.out │ │ ├── 01-types-implement-interface.grats.ts │ │ ├── 01-types-implement-interface.out │ │ ├── 01-types-interface-implement-interface.grats.ts │ │ ├── 01-types-interface-implement-interface.out │ │ ├── 01-types-interface.grats.ts │ │ ├── 01-types-interface.out │ │ ├── 01-types-renaming.grats.ts │ │ ├── 01-types-renaming.out │ │ ├── 02-function-extending-mutation.grats.ts │ │ ├── 02-function-extending-mutation.out │ │ ├── 02-function-extending-query.grats.ts │ │ ├── 02-function-extending-query.out │ │ ├── 02-parameter-property-fields.grats.ts │ │ ├── 02-parameter-property-fields.out │ │ ├── 02-property-and-method.grats.ts │ │ ├── 02-property-and-method.out │ │ ├── 02-static-method-extending-query.grats.ts │ │ ├── 02-static-method-extending-query.out │ │ ├── 04-derived-context-memoized.grats.ts │ │ ├── 04-derived-context-memoized.out │ │ ├── 04-derived-context.grats.ts │ │ ├── 04-derived-context.out │ │ ├── 04-interface-declaration.grats.ts │ │ ├── 04-interface-declaration.out │ │ ├── 04-interface-field-common-impl.grats.ts │ │ ├── 04-interface-field-common-impl.out │ │ ├── 04-interface-implement-interface.grats.ts │ │ ├── 04-interface-implement-interface.out │ │ ├── 04-merged-interface-renaming.grats.ts │ │ ├── 04-merged-interface-renaming.out │ │ ├── 08-specified-by.grats.ts │ │ ├── 08-specified-by.out │ │ ├── 10-one-of-input-descriptions.grats.ts │ │ ├── 10-one-of-input-descriptions.out │ │ ├── 10-one-of-input-exhaustive.grats.ts │ │ ├── 10-one-of-input-exhaustive.out │ │ ├── 10-one-of-input.grats.ts │ │ ├── 10-one-of-input.out │ │ ├── 11-directive-args-defaults.grats.ts │ │ ├── 11-directive-args-defaults.out │ │ ├── 11-directive-args-deprecated.grats.ts │ │ ├── 11-directive-args-deprecated.out │ │ ├── 11-directive-args.grats.ts │ │ ├── 11-directive-args.out │ │ ├── 11-directive-def.grats.ts │ │ ├── 11-directive-def.out │ │ ├── 11-directive-locations.grats.ts │ │ ├── 11-directive-locations.out │ │ ├── 12-directive-annotations-1.grats.ts │ │ ├── 12-directive-annotations-1.out │ │ ├── 12-directive-annotations-2.grats.ts │ │ └── 12-directive-annotations-2.out ├── 05-examples │ ├── 01-apollo-server.md │ ├── 02-express-graphql.md │ ├── 03-graphql-http.md │ ├── 04-yoga.md │ ├── 08-next-js.md │ ├── 09-strict-semantic-nullability.md │ ├── 10-production-app.md │ ├── 11-incremental-migration.md │ ├── _category_.json │ └── index.mdx ├── 05-guides │ ├── 01-workflows.md │ ├── 02-incremental-migration │ │ ├── 01-schema-merging.md │ │ ├── 02-gradual-annotation.md │ │ └── index.md │ ├── 03-subscriptions.mdx │ ├── 04-strict-semantic-nullability.mdx │ ├── 05-dataloader.md │ ├── 06-stream.md │ ├── 07-generics.mdx │ ├── 08-connection-spec.mdx │ ├── _category_.json │ └── snippets │ │ ├── connection-spec.grats.ts │ │ ├── connection-spec.out │ │ ├── result-after.grats.ts │ │ ├── result-after.out │ │ ├── result-before.grats.ts │ │ ├── result-before.out │ │ ├── subscription-example.grats.ts │ │ └── subscription-example.out ├── 06-faq │ ├── 01-limitations.md │ ├── 02-why-use-comments.md │ ├── 03-how-grats-works.md │ ├── 04-structural-vs-nominal-typing.md │ ├── 05-why-prohibit-root-values.mdx │ ├── 06-design-principles.md │ ├── 07-testing-strategy.mdx │ └── _category_.json ├── 07-changelog │ └── index.md ├── gratsSample.grats.ts └── gratsSample.out ├── docusaurus.config.ts ├── netlify.toml ├── package.json ├── plugins └── webpack.js ├── scripts ├── build.sh └── gratsCode.ts ├── sidebars.js ├── src ├── components │ ├── GratsCode.tsx │ ├── HomepageFeatures │ │ ├── index.tsx │ │ ├── snippets │ │ │ ├── homepageExample.grats.ts │ │ │ ├── homepageExample.out │ │ │ ├── homepageExampleFP.grats.ts │ │ │ └── homepageExampleFP.out │ │ └── styles.module.css │ ├── PlaygroundFeatures │ │ ├── ConfigBar.tsx │ │ ├── FormatButton.tsx │ │ ├── ShareButton.tsx │ │ ├── defaultState.ts │ │ ├── editors │ │ │ ├── CodegenOutputView.tsx │ │ │ ├── GraphQLOutputView.tsx │ │ │ ├── InputView.tsx │ │ │ ├── OutputView.tsx │ │ │ ├── ResolverSignatureOutput.tsx │ │ │ └── theme.ts │ │ ├── index.module.css │ │ ├── linter.ts │ │ ├── store.ts │ │ └── urlState.ts │ └── logo.tsx ├── css │ └── custom.css └── pages │ ├── index.module.css │ ├── index.tsx │ └── playground │ └── index.tsx ├── static ├── .nojekyll └── img │ ├── docusaurus.png │ ├── favicon.ico │ ├── grats-og.png │ └── logo.svg └── tsconfig.json /.eslintignore: -------------------------------------------------------------------------------- 1 | dist 2 | src/tests/fixtures/**/*.ts 3 | src/tests/integrationFixtures/**/*.ts 4 | website/build/* 5 | website/**/*.grats.ts -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .parcel-cache 4 | .vercel 5 | 6 | # Local Netlify folder 7 | .netlify 8 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | strict-peer-dependencies=false -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | pnpm-lock.yaml 3 | pnpm-workspace.yaml 4 | dist/ 5 | .parcel-cache 6 | .vercel 7 | website/.docusaurus 8 | website/build 9 | src/tests/fixtures/user_error/InvalidSyntax.invalid.ts 10 | **/schema.graphql 11 | **/schema.ts 12 | examples/incremental-migration/schemas/gratsGeneratedSchema.ts 13 | .next 14 | 15 | # Local Netlify folder 16 | .netlify 17 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Grats Changelog 2 | 3 | This document is now part of the website. Read it at https://grats.capt.dev/docs/changelog/ or [edit the source](./website/docs/07-changelog/index.md). 4 | -------------------------------------------------------------------------------- /examples/apollo-server/Query.ts: -------------------------------------------------------------------------------- 1 | import IPerson from "./interfaces/IPerson"; 2 | import User from "./models/User"; 3 | 4 | /** @gqlQueryField */ 5 | export function person(): IPerson { 6 | return new User(); 7 | } 8 | -------------------------------------------------------------------------------- /examples/apollo-server/README.md: -------------------------------------------------------------------------------- 1 | # Grats + Apollo Server 2 | 3 | Simple demo project integrating [Grats](https://grats.capt.dev/) and [Apollo Server](https://www.npmjs.com/package/@apollo/server). 4 | 5 | ## Running the demo 6 | 7 | - `$ pnpm install` 8 | - `$ pnpm run start` 9 | -------------------------------------------------------------------------------- /examples/apollo-server/interfaces/IPerson.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | export default interface IPerson { 3 | /** @gqlField */ 4 | name(): string; 5 | } 6 | -------------------------------------------------------------------------------- /examples/apollo-server/models/Group.ts: -------------------------------------------------------------------------------- 1 | import User from "./User"; 2 | 3 | /** @gqlType */ 4 | export default class Group { 5 | /** @gqlField */ 6 | description: string; 7 | 8 | constructor() { 9 | this.description = "A group of people"; 10 | } 11 | 12 | /** @gqlField */ 13 | name(): string { 14 | return "Pal's Club"; 15 | } 16 | /** @gqlField */ 17 | async members(): Promise { 18 | return [new User()]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/apollo-server/schema.graphql: -------------------------------------------------------------------------------- 1 | # Schema generated by Grats (https://grats.capt.dev) 2 | # Do not manually edit. Regenerate by running `npx grats`. 3 | interface IPerson { 4 | name: String! 5 | } 6 | 7 | type Group { 8 | description: String! 9 | members: [User!]! 10 | name: String! 11 | } 12 | 13 | type Query { 14 | allUsers: [User!]! 15 | me: User! 16 | person: IPerson! 17 | } 18 | 19 | type User implements IPerson { 20 | groups: [Group!]! 21 | name: String! 22 | } 23 | -------------------------------------------------------------------------------- /examples/apollo-server/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "grats": { 3 | "nullableByDefault": false 4 | }, 5 | "compilerOptions": { 6 | "outDir": "dist", 7 | "module": "NodeNext", 8 | "moduleResolution": "NodeNext", 9 | "target": "esnext", 10 | "lib": ["esnext"], 11 | "strict": true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/express-graphql-http/interfaces/IPerson.ts: -------------------------------------------------------------------------------- 1 | import User from "../models/User"; 2 | 3 | /** @gqlInterface */ 4 | export default interface IPerson { 5 | /** @gqlField */ 6 | name(): string; 7 | } 8 | 9 | /** @gqlQueryField */ 10 | export function person(): IPerson { 11 | return new User(); 12 | } 13 | -------------------------------------------------------------------------------- /examples/express-graphql-http/models/Group.ts: -------------------------------------------------------------------------------- 1 | import User from "./User"; 2 | 3 | /** @gqlType */ 4 | export default class Group { 5 | /** @gqlField */ 6 | description: string; 7 | 8 | constructor() { 9 | this.description = "A group of people"; 10 | } 11 | 12 | /** @gqlField */ 13 | name(): string { 14 | return "Pal's Club"; 15 | } 16 | /** @gqlField */ 17 | async members(): Promise { 18 | return [new User()]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/express-graphql-http/schema.graphql: -------------------------------------------------------------------------------- 1 | # Schema generated by Grats (https://grats.capt.dev) 2 | # Do not manually edit. Regenerate by running `npx grats`. 3 | interface IPerson { 4 | name: String! 5 | } 6 | 7 | type Group { 8 | description: String! 9 | members: [User!]! 10 | name: String! 11 | } 12 | 13 | type Query { 14 | allUsers: [User!]! 15 | me: User! 16 | person: IPerson! 17 | } 18 | 19 | type User implements IPerson { 20 | groups: [Group!]! 21 | name: String! 22 | } 23 | -------------------------------------------------------------------------------- /examples/express-graphql-http/server.ts: -------------------------------------------------------------------------------- 1 | import * as express from "express"; 2 | import { createHandler } from "graphql-http/lib/use/express"; 3 | import { getSchema } from "./schema"; 4 | 5 | const app = express(); 6 | 7 | app.post( 8 | "/graphql", 9 | createHandler({ 10 | schema: getSchema(), 11 | }), 12 | ); 13 | 14 | app.listen(4000); 15 | console.log("Running a GraphQL API server at http://localhost:4000/graphql"); 16 | -------------------------------------------------------------------------------- /examples/express-graphql-http/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | // Most ts-node options can be specified here using their programmatic names. 3 | "ts-node": { 4 | "files": true, 5 | // It is faster to skip typechecking. 6 | // Remove if you want ts-node to do typechecking. 7 | "transpileOnly": false 8 | }, 9 | "grats": { 10 | "nullableByDefault": false 11 | }, 12 | "compilerOptions": { 13 | "outDir": "dist", 14 | "lib": ["esnext"], 15 | "strict": true 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/express-graphql/interfaces/IPerson.ts: -------------------------------------------------------------------------------- 1 | import User from "../models/User"; 2 | 3 | /** @gqlInterface */ 4 | export default interface IPerson { 5 | /** @gqlField */ 6 | name(): string; 7 | } 8 | 9 | /** @gqlQueryField */ 10 | export function person(): IPerson { 11 | return new User(); 12 | } 13 | -------------------------------------------------------------------------------- /examples/express-graphql/models/Group.ts: -------------------------------------------------------------------------------- 1 | import User from "./User"; 2 | 3 | /** @gqlType */ 4 | export default class Group { 5 | /** @gqlField */ 6 | description: string; 7 | 8 | constructor() { 9 | this.description = "A group of people"; 10 | } 11 | 12 | /** @gqlField */ 13 | name(): string { 14 | return "Pal's Club"; 15 | } 16 | /** @gqlField */ 17 | async members(): Promise { 18 | return [new User()]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/express-graphql/schema.graphql: -------------------------------------------------------------------------------- 1 | # Schema generated by Grats (https://grats.capt.dev) 2 | # Do not manually edit. Regenerate by running `npx grats`. 3 | interface IPerson { 4 | name: String! 5 | } 6 | 7 | type Group { 8 | description: String! 9 | members: [User!]! 10 | name: String! 11 | } 12 | 13 | type Query { 14 | allUsers: [User!]! 15 | me: User! 16 | person: IPerson! 17 | } 18 | 19 | type User implements IPerson { 20 | groups: [Group!]! 21 | name: String! 22 | } 23 | -------------------------------------------------------------------------------- /examples/express-graphql/server.ts: -------------------------------------------------------------------------------- 1 | import * as express from "express"; 2 | import { graphqlHTTP } from "express-graphql"; 3 | import { getSchema } from "./schema"; 4 | 5 | const app = express(); 6 | 7 | app.use( 8 | "/graphql", 9 | graphqlHTTP({ 10 | schema: getSchema(), 11 | graphiql: true, 12 | }), 13 | ); 14 | app.listen(4000); 15 | console.log("Running a GraphQL API server at http://localhost:4000/graphql"); 16 | -------------------------------------------------------------------------------- /examples/incremental-migration/gratsSchema.graphql: -------------------------------------------------------------------------------- 1 | # DO NOT USE DIRECTLY. Prefer the merged schema in `../schema.graphql`. 2 | type Query { 3 | user(id: ID!): User 4 | } 5 | 6 | type User { 7 | firstName: String! 8 | fullName: String! 9 | id: ID! 10 | lastName: String! 11 | } 12 | -------------------------------------------------------------------------------- /examples/incremental-migration/server.ts: -------------------------------------------------------------------------------- 1 | import { createServer } from "node:http"; 2 | import { createYoga } from "graphql-yoga"; 3 | import { schema } from "./schemas/mergedSchema"; 4 | 5 | const yoga = createYoga({ schema }); 6 | 7 | const server = createServer(yoga); 8 | 9 | server.listen(4000, () => { 10 | console.log("Running a GraphQL API server at http://localhost:4000/graphql"); 11 | }); 12 | -------------------------------------------------------------------------------- /examples/incremental-migration/testConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "testCases": [ 3 | { 4 | "name": "Simple query", 5 | "query": "query { user(id: 3) { fullName } }", 6 | "variables": {}, 7 | "expected": { "data": { "user": { "fullName": "Loraine Swaniawski" } } } 8 | } 9 | ] 10 | } 11 | -------------------------------------------------------------------------------- /examples/next-js/README.md: -------------------------------------------------------------------------------- 1 | # Grats + Next.js + Yoga 2 | 3 | Simple demo project integrating [Grats](https://grats.capt.dev/) and [Next.js](https://nextjs.org/) and [Yoga](https://github.com/dotansimha/graphql-yoga). 4 | 5 | ## Running the demo 6 | 7 | - `$ pnpm install` 8 | - `$ pnpm run start` 9 | -------------------------------------------------------------------------------- /examples/next-js/app/api/graphql/Query.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Note: This file is split out from `route.ts` because Next has 3 | * special expectations about the meaning of exports from `route.ts`. 4 | */ 5 | 6 | import IPerson from "./interfaces/IPerson"; 7 | import User from "./models/User"; 8 | 9 | /** @gqlQueryField */ 10 | export function me(): User { 11 | return new User(); 12 | } 13 | /** @gqlQueryField */ 14 | export function person(): IPerson { 15 | return new User(); 16 | } 17 | -------------------------------------------------------------------------------- /examples/next-js/app/api/graphql/interfaces/IPerson.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | export default interface IPerson { 3 | /** @gqlField */ 4 | name(): string; 5 | } 6 | -------------------------------------------------------------------------------- /examples/next-js/app/api/graphql/models/Group.ts: -------------------------------------------------------------------------------- 1 | import User from "./User"; 2 | 3 | /** @gqlType */ 4 | export default class Group { 5 | /** @gqlField */ 6 | description: string; 7 | 8 | constructor() { 9 | this.description = "A group of people"; 10 | } 11 | 12 | /** @gqlField */ 13 | name(): string { 14 | return "Pal's Club"; 15 | } 16 | /** @gqlField */ 17 | async members(): Promise { 18 | return [new User()]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/next-js/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {}; 3 | 4 | module.exports = nextConfig; 5 | -------------------------------------------------------------------------------- /examples/next-js/schema.graphql: -------------------------------------------------------------------------------- 1 | # Schema generated by Grats (https://grats.capt.dev) 2 | # Do not manually edit. Regenerate by running `npx grats`. 3 | interface IPerson { 4 | name: String! 5 | } 6 | 7 | type Group { 8 | description: String! 9 | members: [User!]! 10 | name: String! 11 | } 12 | 13 | type Query { 14 | allUsers: [User!]! 15 | me: User! 16 | person: IPerson! 17 | } 18 | 19 | type User implements IPerson { 20 | groups: [Group!]! 21 | name: String! 22 | } 23 | -------------------------------------------------------------------------------- /examples/next-js/testConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "route": "api/graphql" 3 | } 4 | -------------------------------------------------------------------------------- /examples/production-app/PubSub.ts: -------------------------------------------------------------------------------- 1 | import { createPubSub } from "graphql-yoga"; 2 | 3 | export type EventTypes = { 4 | postLiked: [postId: string]; 5 | randomNumber: [number]; 6 | }; 7 | 8 | export const PubSub = createPubSub(); 9 | -------------------------------------------------------------------------------- /examples/production-app/models/Model.ts: -------------------------------------------------------------------------------- 1 | import { VC } from "../ViewerContext"; 2 | 3 | /** 4 | * Generic model class built around a database row 5 | */ 6 | export abstract class Model { 7 | constructor(protected vc: VC, protected row: R) {} 8 | localID(): string { 9 | return this.row.id; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /examples/production-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "grats": {}, 3 | "compilerOptions": { 4 | "outDir": "dist", 5 | "module": "NodeNext", 6 | "moduleResolution": "NodeNext", 7 | "target": "esnext", 8 | "lib": ["esnext"], 9 | "strict": true, 10 | "skipLibCheck": true 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/strict-semantic-nullability/README.md: -------------------------------------------------------------------------------- 1 | # Grats + Strict Semantic Nullability 2 | 3 | This example demonstrates Grats' experimental support for [Strict Semantic Nullability](https://grats.capt.dev/docs/guides/strict-semantic-nullability). 4 | 5 | ## Running the demo 6 | 7 | - `$ pnpm install` 8 | - `$ pnpm run start` 9 | -------------------------------------------------------------------------------- /examples/strict-semantic-nullability/interfaces/IPerson.ts: -------------------------------------------------------------------------------- 1 | import User from "../models/User"; 2 | 3 | /** @gqlInterface */ 4 | export default interface IPerson { 5 | /** @gqlField */ 6 | name(): string; 7 | } 8 | 9 | /** @gqlQueryField */ 10 | export function person(): IPerson { 11 | return new User(); 12 | } 13 | -------------------------------------------------------------------------------- /examples/strict-semantic-nullability/models/Group.ts: -------------------------------------------------------------------------------- 1 | import User from "./User"; 2 | 3 | /** @gqlType */ 4 | export default class Group { 5 | /** @gqlField */ 6 | description: string; 7 | 8 | constructor() { 9 | this.description = "A group of people"; 10 | } 11 | 12 | /** @gqlField */ 13 | name(): string { 14 | return "Pal's Club"; 15 | } 16 | /** @gqlField */ 17 | async members(): Promise { 18 | return [new User()]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/strict-semantic-nullability/server.ts: -------------------------------------------------------------------------------- 1 | import { createServer } from "node:http"; 2 | import { createYoga } from "graphql-yoga"; 3 | import { getSchema } from "./schema"; 4 | 5 | const yoga = createYoga({ 6 | schema: getSchema(), 7 | }); 8 | 9 | const server = createServer(yoga); 10 | 11 | server.listen(4000, () => { 12 | console.log("Running a GraphQL API server at http://localhost:4000/graphql"); 13 | }); 14 | -------------------------------------------------------------------------------- /examples/strict-semantic-nullability/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "grats": { 3 | "nullableByDefault": true, 4 | "strictSemanticNullability": true 5 | }, 6 | "compilerOptions": { 7 | "outDir": "dist", 8 | "module": "NodeNext", 9 | "moduleResolution": "NodeNext", 10 | "target": "esnext", 11 | "lib": ["esnext"], 12 | "strict": true, 13 | "skipLibCheck": true 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /examples/yoga/README.md: -------------------------------------------------------------------------------- 1 | # Grats + Yoga + node:http 2 | 3 | Simple demo project integrating [Grats](https://grats.capt.dev/) and [Yoga](https://github.com/dotansimha/graphql-yoga) with Node's built-in HTTP server. This example also includes an working example of GraphQL subscriptions. 4 | 5 | ## Running the demo 6 | 7 | - `$ pnpm install` 8 | - `$ pnpm run start` 9 | -------------------------------------------------------------------------------- /examples/yoga/Subscription.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "grats"; 2 | 3 | /** @gqlSubscriptionField */ 4 | export async function* countdown(args: { from: Int }): AsyncIterable { 5 | for (let i = args.from; i >= 0; i--) { 6 | await new Promise((resolve) => setTimeout(resolve, 1000)); 7 | yield i; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /examples/yoga/interfaces/IPerson.ts: -------------------------------------------------------------------------------- 1 | import User from "../models/User"; 2 | 3 | /** @gqlInterface */ 4 | export default interface IPerson { 5 | /** @gqlField */ 6 | name(): string; 7 | } 8 | 9 | /** @gqlQueryField */ 10 | export function person(): IPerson { 11 | return new User(); 12 | } 13 | -------------------------------------------------------------------------------- /examples/yoga/models/Group.ts: -------------------------------------------------------------------------------- 1 | import User from "./User"; 2 | 3 | /** @gqlType */ 4 | export default class Group { 5 | /** @gqlField */ 6 | description: string; 7 | 8 | constructor() { 9 | this.description = "A group of people"; 10 | } 11 | 12 | /** @gqlField */ 13 | name(): string { 14 | return "Pal's Club"; 15 | } 16 | /** @gqlField */ 17 | async members(): Promise { 18 | return [new User()]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /examples/yoga/server.ts: -------------------------------------------------------------------------------- 1 | import { createServer } from "node:http"; 2 | import { createYoga } from "graphql-yoga"; 3 | import { getSchema } from "./schema"; 4 | 5 | const yoga = createYoga({ 6 | schema: getSchema(), 7 | }); 8 | 9 | const server = createServer(yoga); 10 | 11 | server.listen(4000, () => { 12 | console.log("Running a GraphQL API server at http://localhost:4000/graphql"); 13 | }); 14 | -------------------------------------------------------------------------------- /examples/yoga/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "grats": { 3 | "nullableByDefault": false 4 | }, 5 | "compilerOptions": { 6 | "outDir": "dist", 7 | "module": "NodeNext", 8 | "moduleResolution": "NodeNext", 9 | "target": "esnext", 10 | "lib": ["esnext"], 11 | "strict": true, 12 | "skipLibCheck": true 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /grats-ts-plugin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "grats-ts-plugin", 3 | "version": "0.0.2", 4 | "license": "MIT", 5 | "main": "./", 6 | "module": "./index.js", 7 | "peerDependencies": { 8 | "grats": ">=0.0.19" 9 | }, 10 | "prettier": {} 11 | } 12 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'website' 3 | - 'examples/*' 4 | - 'grats-ts-plugin' -------------------------------------------------------------------------------- /scripts/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Exit if any command fails 4 | set -e 5 | 6 | # Ensure we are in the website directory 7 | cd "$(dirname "$0")/.." 8 | 9 | pnpm i 10 | pnpm run build 11 | pnpm version patch # or minor or major 12 | pnpm publish 13 | git push --tags 14 | git push origin -------------------------------------------------------------------------------- /src/Types.ts: -------------------------------------------------------------------------------- 1 | import type { GraphQLResolveInfo } from "graphql"; 2 | 3 | /** @gqlScalar */ 4 | export type Float = number; 5 | /** @gqlScalar */ 6 | export type Int = number; 7 | /** @gqlScalar */ 8 | export type ID = string; 9 | 10 | /** @gqlInfo */ 11 | export type GqlInfo = GraphQLResolveInfo; 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/ArgReferencesNonGqlType.invalid.ts: -------------------------------------------------------------------------------- 1 | type NotGraphql = any; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | hello({ greeting }: { greeting: NotGraphql }): string { 7 | return "Hello world!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/ArgWithNoType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting }: { greeting }): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/ArgumentWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(args: { 5 | /** The greeting to use. */ 6 | greeting: string; 7 | }): string { 8 | return `${args.greeting} world!`; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/AsyncIterableArgument.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(args: { greeting: AsyncIterable }): string { 5 | return `${args.greeting} world!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/CustomScalarArgument.ts: -------------------------------------------------------------------------------- 1 | /** @gqlScalar */ 2 | type MyString = string; 3 | 4 | /** @gqlType */ 5 | export default class SomeType { 6 | /** @gqlField */ 7 | hello({ greeting }: { greeting: MyString }): string { 8 | return "Hello world!"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/DeprecatedArgument.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ 5 | greeting, 6 | }: { 7 | /** @deprecated Not used anymore */ 8 | greeting?: string | null; 9 | }): string { 10 | return "Hello world!"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/DeprecatedRequiredArgument.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ 5 | greeting, 6 | }: { 7 | /** @deprecated Not used anymore */ 8 | greeting: string; 9 | }): string { 10 | return "Hello world!"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/GqlTypeUsedAsPositionalArg.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Greeting = { 3 | name: string; 4 | salutation: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export default class SomeType { 9 | /** @gqlField */ 10 | hello(greeting: Greeting): string { 11 | return `${greeting.salutation} ${greeting.name}!`; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/MultipleParamsTypedAsTypeLiteral.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(args: { greeting: string }, alsoArgs: { farewell: string }): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/NoArgsWithNever.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(args: never): string { 5 | console.log("hello"); 6 | return "Hello world!"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/NoArgsWithUnknown.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(args: unknown): string { 5 | console.log("hello"); 6 | return "Hello world!"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/NoTypeAnnotation.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(args): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/NullableArguments.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello1({ greeting }: { greeting?: string | null }): string { 5 | return "Hello world!"; 6 | } 7 | /** @gqlField */ 8 | hello2({ 9 | greeting, 10 | }: { 11 | greeting?: string | undefined | void | undefined; 12 | }): string { 13 | return "Hello world!"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/ObjectLiteralArgument.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting }: { greeting: { foo: string; bar: string } }): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/OpaqueArgType.invalid.ts: -------------------------------------------------------------------------------- 1 | type SomeType = any; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | hello({ greeting }: SomeType): string { 7 | return "Hello world!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/OptionalArgument.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting }: { greeting?: string | null }): string { 5 | return `${greeting ?? "Hello"} World!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/OptionalNonNullableArgumentWithDefault.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting = "Hello" }: { greeting?: string }): string { 5 | return `${greeting ?? "Hello"} World!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PositionalArgAndArgs.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Greeting = { 3 | name: string; 4 | salutation: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export default class SomeType { 9 | /** @gqlField */ 10 | hello(greeting: Greeting, args: { notGreeting: string }): string { 11 | return `${greeting.salutation} ${greeting.name} ${args.notGreeting}!`; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PositionalArgDeprecatedOptional.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Greeting = { 3 | name: string; 4 | salutation: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export default class SomeType { 9 | /** @gqlField */ 10 | hello( 11 | /** @deprecated Unused! */ 12 | greeting?: Greeting | null, 13 | ): string { 14 | return `Hullo`; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PositionalArgDeprecatedWithDefault.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Greeting = { 3 | name: string; 4 | salutation: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export default class SomeType { 9 | /** @gqlField */ 10 | hello( 11 | /** @deprecated Unused! */ 12 | greeting: Greeting = { name: "Alice", salutation: "Hullo" }, 13 | ): string { 14 | return `Hullo`; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PositionalArgOptional.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Greeting = { 3 | name: string; 4 | salutation: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export default class SomeType { 9 | /** @gqlField */ 10 | hello(greeting?: string | null): string { 11 | return `${greeting ?? "Hello"} World`; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PositionalArgOptionalNotNullable.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Greeting = { 3 | name: string; 4 | salutation: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export default class SomeType { 9 | /** @gqlField */ 10 | hello(greeting?: string): string { 11 | return `${greeting ?? "Hello"} World`; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PositionalArgWithDefault.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(greeting: string = "Hello"): string { 5 | return `${greeting} World`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PositionalArgWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Greeting = { 3 | name: string; 4 | salutation: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export default class SomeType { 9 | /** @gqlField */ 10 | hello( 11 | /** How to greet the user */ 12 | greeting: Greeting, 13 | ): string { 14 | return `${greeting.salutation} ${greeting.name}!`; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/PromiseArgument.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(args: { greeting: Promise }): string { 5 | return `${args.greeting} world!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/StringArgument.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting }: { greeting: string }): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/arguments/TupleLiteralArgument.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting }: { greeting: [string] }): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/built_in_scalars/FloatField.ts: -------------------------------------------------------------------------------- 1 | import { Float } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | ratio(): Float { 7 | return 10; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/built_in_scalars/FloatFieldAliasedImport.ts: -------------------------------------------------------------------------------- 1 | import { Float as LocalFloat } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | ratio(): LocalFloat { 7 | return 10; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/built_in_scalars/IdField.ts: -------------------------------------------------------------------------------- 1 | import { ID } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | id(): ID { 7 | return "QUERY_ID"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/built_in_scalars/IntField.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | age(): Int { 7 | return 10; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/blockCommentThreeStars.invalid.ts: -------------------------------------------------------------------------------- 1 | // { "tsVersion": "<=5.0.2" } 2 | /*** @gqlType */ 3 | class User {} 4 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/commentFollowsDecorator.invalid.ts: -------------------------------------------------------------------------------- 1 | @ObjectType() 2 | /** @gqlType */ 3 | export default class Composer { 4 | @Field() 5 | /** @gqlField */ 6 | url(): string { 7 | return `/composer/`; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/detachedBlockComment.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType 3 | */ 4 | /** 5 | * Foo 6 | */ 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/detachedBlockCommentNotJSDocWithoutStar.invalid.ts: -------------------------------------------------------------------------------- 1 | /* 2 | @gqlType 3 | */ 4 | /** 5 | * Foo 6 | */ 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/detachedBlockCommentWithInvalidTagName.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlTyp 3 | */ 4 | /** 5 | * Foo 6 | */ 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/detachedBlockCommentWithKillsParent.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @killsParentOnException 3 | */ 4 | /** 5 | * Foo 6 | */ 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/detachedBlockCommentWithoutStar.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | @gqlType 3 | */ 4 | /** 5 | * Foo 6 | */ 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/invalidTagInLinecomment.ts: -------------------------------------------------------------------------------- 1 | // @gqlTyp 2 | export default class Composer { 3 | url(): string { 4 | return `/composer/`; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/lineComment.invalid.ts: -------------------------------------------------------------------------------- 1 | // @gqlType 2 | export default class Composer { 3 | // @gqlField 4 | url(): string { 5 | return `/composer/`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/lineCommentWrongCasing.invalid.ts: -------------------------------------------------------------------------------- 1 | // @GQLtYPE 2 | export default class Composer { 3 | // @gqlfield 4 | url(): string { 5 | return `/composer/`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/comments/nonJSDocBlockComment.invalid.ts: -------------------------------------------------------------------------------- 1 | // Oops! Forgot to use two asterisks for the JSDoc block comment. 2 | 3 | /* @gqlType */ 4 | class Composer {} 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/headerIsArrayWithNumber.invalid.ts: -------------------------------------------------------------------------------- 1 | // {"schemaHeader": ["Hello", 1]} 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/headerIsArrayWithNumber.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // {"schemaHeader": ["Hello", 1]} 5 | /** @gqlType */ 6 | export default class SomeType { 7 | /** @gqlField */ 8 | hello: string; 9 | } 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | Grats: If the Grats config option `schemaHeader` is an array, it must be an array of strings. -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/importModuleSpecifierEnding.ts: -------------------------------------------------------------------------------- 1 | // {"importModuleSpecifierEnding": ".js"} 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | hello: string; 7 | } 8 | 9 | /** @gqlField */ 10 | export function greeting(t: SomeType): string { 11 | return t.hello + " world!"; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/invalidKey.invalid.ts: -------------------------------------------------------------------------------- 1 | // {"invalidKey": "Oops"} 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/invalidKey.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // {"invalidKey": "Oops"} 5 | /** @gqlType */ 6 | export default class SomeType { 7 | /** @gqlField */ 8 | hello: string; 9 | } 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | Grats: Unknown Grats config option `invalidKey` -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/multipleInvalidKeys.invalid.ts: -------------------------------------------------------------------------------- 1 | // {"invalidKey": "Oops", "anotherInvalidKey": "Oops"} 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/multipleInvalidKeys.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // {"invalidKey": "Oops", "anotherInvalidKey": "Oops"} 5 | /** @gqlType */ 6 | export default class SomeType { 7 | /** @gqlField */ 8 | hello: string; 9 | } 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | Grats: Unknown Grats config option `invalidKey` -------------------------------------------------------------------------------- /src/tests/fixtures/configOptions/nonNullableIsNull.invalid.ts: -------------------------------------------------------------------------------- 1 | // {"tsSchema": null} 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/DefineCustomScalar.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlScalar */ 8 | type MyUrl = string; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/DefineCustomScalarWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** 8 | * Use this for URLs. 9 | * @gqlScalar 10 | */ 11 | type MyUrl = string; 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/DefineRenamedCustomScalar.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlScalar CustomName */ 8 | type MyUrl = string; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/SpecifiedBy.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlScalar 3 | * @gqlAnnotate specifiedBy(url: "https://tools.ietf.org/html/rfc4122") 4 | */ 5 | export type UUID = string; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/SpecifiedByMissingUrlinvalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlScalar 3 | * @gqlAnnotate specifiedBy 4 | */ 5 | export type UUID = string; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/SpecifiedByMissingUrlinvalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** 5 | * @gqlScalar 6 | * @gqlAnnotate specifiedBy 7 | */ 8 | export type UUID = string; 9 | 10 | ----------------- 11 | OUTPUT 12 | ----------------- 13 | GraphQL request:1:1 - error: Directive "@specifiedBy" argument "url" of type "String!" is required, but it was not provided. 14 | 15 | 1 @specifiedBy 16 | ~~~~~~~~~~~~ 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/SpecifiedByOldSyntax.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlScalar 3 | * @specifiedBy https://tools.ietf.org/html/rfc4122 4 | */ 5 | export type UUID = string; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/SpecifiedByOnEnum.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlEnum 3 | * @gqlAnnotate specifiedBy(url: "https://tools.ietf.org/html/rfc4122") 4 | */ 5 | export type MyEnum = "A" | "B" | "C"; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/TagAttachedToWrongNode.ts: -------------------------------------------------------------------------------- 1 | /** @gqlScalar Matrix */ 2 | function Foo() {} 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/custom_scalars/TagAttachedToWrongNode.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlScalar Matrix */ 5 | function Foo() {} 6 | 7 | ----------------- 8 | OUTPUT 9 | ----------------- 10 | src/tests/fixtures/custom_scalars/TagAttachedToWrongNode.ts:1:5 - error: `@gqlScalar` can only be used on type alias declarations. e.g. `type MyScalar = string` 11 | 12 | 1 /** @gqlScalar Matrix */ 13 | ~~~~~~~~~~~~~~~~~~ 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentArray.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | someField1({ 5 | inputs = ["hello", "there"], 6 | }: { 7 | inputs?: string[] | null; 8 | }): string { 9 | if (inputs === null) { 10 | return "got null"; 11 | } 12 | return inputs.join("|"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentArrayValuesInvalid.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | someField1({ 5 | inputs = [func(), func()], 6 | }: { 7 | inputs?: string[] | null; 8 | }): string { 9 | if (inputs === null) { 10 | return "got null"; 11 | } 12 | return inputs.join("|"); 13 | } 14 | } 15 | 16 | function func(): string { 17 | return "sup"; 18 | } 19 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentBooleanLiteral.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | someField1({ greet = false }: { greet?: boolean | null }): string { 5 | if (!greet) return ""; 6 | return "hello"; 7 | } 8 | 9 | /** @gqlField */ 10 | someField2({ greet = true }: { greet?: boolean | null }): string { 11 | if (!greet) return ""; 12 | return "hello"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentNullLiteral.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | someField1({ hello = null }: { hello?: string | null }): string { 5 | if (hello === null) return "hello"; 6 | return "hello"; 7 | } 8 | /** @gqlField */ 9 | someField2({ hello = undefined }: { hello?: string | undefined }): string { 10 | if (hello === null) return "hello"; 11 | return "hello"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentNumberLiteral.ts: -------------------------------------------------------------------------------- 1 | import { Float, Int } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | intField({ count = 10 }: { count: Int }): string { 7 | return `${count} world!`; 8 | } 9 | /** @gqlField */ 10 | floatField({ scale = 10.0 }: { scale: Float }): string { 11 | return `${scale} world!`; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentObjectLiteral.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | someField1({ 7 | input = { first: 10, offset: 100 }, 8 | }: { 9 | input?: ConnectionInput | null; 10 | }): string { 11 | return "hello"; 12 | } 13 | } 14 | 15 | /** @gqlInput */ 16 | type ConnectionInput = { 17 | first: Int; 18 | offset: Int; 19 | }; 20 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentPropertyName.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ if: x = false }: { if: boolean }): string { 5 | return x ? "hello" : "world"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentStringLiteral.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting = "hello" }: { greeting: string }): string { 5 | return `${greeting} world!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentStringLiteralBackticks.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting = `hello` }: { greeting: string }): string { 5 | return `${greeting} world!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/DefaultArgumentStringLiteralBackticksInterpolated.invalid.ts: -------------------------------------------------------------------------------- 1 | const CONSTANT = "constant"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | hello({ greeting = `hello ${CONSTANT}` }: { greeting: string }): string { 7 | return `${greeting} world!`; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/default_values/NonLiteralDefaultValue.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello({ greeting = String(Math.random()) }: { greeting: string }): string { 5 | return `${greeting} world!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/descriptions/BlankLinesAroundDescription.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * 4 | * 5 | * 6 | * 7 | * 8 | * 9 | * 10 | * 11 | * Sup 12 | * 13 | * 14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * @gqlType 21 | */ 22 | class SomeType { 23 | /** @gqlField */ 24 | name: string; 25 | } 26 | -------------------------------------------------------------------------------- /src/tests/fixtures/descriptions/BlankLinesFollowTypeTag.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType 3 | * 4 | * 5 | * 6 | * 7 | * 8 | */ 9 | class SomeType { 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/descriptions/DescriptionFollowsTypeTag.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType 3 | * 4 | * This is a note for myself 5 | */ 6 | export type Query = unknown; 7 | 8 | /** @gqlField */ 9 | export function queryField(_: Query): string { 10 | return ""; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/descriptions/DescriptionOnLineOfTypeTag.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType This is a note for myself 3 | */ 4 | export type Query = unknown; 5 | 6 | /** @gqlField */ 7 | export function queryField(_: Query): string { 8 | return ""; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/descriptions/DescriptionWithGitHubHandle.ts: -------------------------------------------------------------------------------- 1 | // { "tsVersion": "5.0.2" } 2 | /** 3 | * This type was added by @captbaritone! 4 | * @gqlType 5 | */ 6 | class SomeType { 7 | /** @gqlField */ 8 | name: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/descriptions/MultilineDescription.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * ’Twas brillig, and the slithy toves 3 | * Did gyre and gimble in the wabe: 4 | * All mimsy were the borogoves, 5 | * And the mome raths outgrabe. 6 | * 7 | * @gqlType 8 | */ 9 | class SomeType { 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/descriptions/RenameFollowedByDescription.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType User 3 | * 4 | * The user (oops, this should go up above!) 5 | */ 6 | class SomeType { 7 | /** @gqlField */ 8 | name: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirective.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective on FIELD_DEFINITION 4 | */ 5 | export function customDirective() {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveAdditionalArgsAreIgnored.ts: -------------------------------------------------------------------------------- 1 | import { GraphQLFieldResolver } from "graphql"; 2 | 3 | /** 4 | * This is my custom directive. 5 | * @gqlDirective on FIELD_DEFINITION 6 | */ 7 | export function customDirective( 8 | args: { someArg: string }, 9 | _someArg: GraphQLFieldResolver, 10 | ) { 11 | // 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveArgsIsNever.ts: -------------------------------------------------------------------------------- 1 | import { GraphQLFieldResolver } from "graphql"; 2 | 3 | /** 4 | * This is my custom directive. 5 | * @gqlDirective on FIELD_DEFINITION 6 | */ 7 | export function customDirective( 8 | _: never, 9 | _someArg: GraphQLFieldResolver, 10 | ) { 11 | // 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveCustomName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective aBetterName on FIELD_DEFINITION 4 | */ 5 | export function customDirective() {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveLocationInvalid.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective on WHOOPS 4 | */ 5 | export function customDirective() {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveMultipleLocations.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective on FIELD_DEFINITION | ARGUMENT_DEFINITION 4 | */ 5 | function customDirective() {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveNoLocation.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective 4 | */ 5 | function customDirective() {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveOnIsNotString.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective on FIELD_DEFINITION This is a description with {@link https://example.com some link} 4 | * and `inline code` to demonstrate structured comments. 5 | */ 6 | function customDirective() {} 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveReadsContext.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlContext */ 2 | type Ctx = {}; 3 | 4 | /** 5 | * This is my custom directive. 6 | * @gqlDirective on FIELD_DEFINITION 7 | */ 8 | export function customDirective(oops: Ctx) {} 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveRepeatable.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective repeatable on FIELD_DEFINITION 4 | */ 5 | function customDirective() {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveWithArgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective on FIELD_DEFINITION 4 | */ 5 | export function customDirective(arg: { someArg: string }) {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveWithArgsNonScalar.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type SomeInput = { 3 | someField: string; 4 | }; 5 | 6 | /** 7 | * This is my custom directive. 8 | * @gqlDirective on FIELD_DEFINITION 9 | */ 10 | export function customDirective(args: { someArg: SomeInput }) {} 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/defineCustomDirectiveWithArgsWithDefault.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective on FIELD_DEFINITION 4 | */ 5 | export function customDirective({ someArg = "Hello" }: { someArg: string }) {} 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveArgFieldInvalid.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | type MyInput = { a: string }; 5 | /** 6 | * This is my custom directive. 7 | * @gqlDirective on FIELD_DEFINITION 8 | */ 9 | export function customDirective(args: { foo: MyInput }) {} 10 | 11 | /** 12 | * @gqlQueryField 13 | * @gqlAnnotate customDirective(foo: {a: 10}) 14 | */ 15 | export function myQueryField(): string { 16 | return "myQueryField"; 17 | } 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveArgInvalidOneOf.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | type MyInput = { a: string } | { b: string }; 5 | /** 6 | * This is my custom directive. 7 | * @gqlDirective on FIELD_DEFINITION 8 | */ 9 | export function customDirective(args: { foo: MyInput }) {} 10 | 11 | /** 12 | * @gqlQueryField 13 | * @gqlAnnotate customDirective(foo: {a: "a", b: "b"}) 14 | */ 15 | export function myQueryField(): string { 16 | return "myQueryField"; 17 | } 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveArgumentNameIsStringLiteralWithDefault.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/166#issuecomment-2753130827 2 | 3 | /** 4 | * @gqlDirective on FRAGMENT_SPREAD | INLINE_FRAGMENT 5 | */ 6 | function defer({ 7 | label, 8 | if: _ = true, // anonymous alias 9 | }: { 10 | label: string; 11 | if?: boolean | null; 12 | }): void {} 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveNotConst.invalid.ts: -------------------------------------------------------------------------------- 1 | // Because @myDirective is followed by `(` we assume it's expected to be parsed 2 | // as a directive even though it's not defined. 3 | 4 | /** 5 | * @gqlQueryField 6 | * @gqlAnnotate myDirective(someArg: $foo) 7 | */ 8 | export function myQueryField(): string { 9 | return "myQueryField"; 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnArgumentDefinition.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on ARGUMENT_DEFINITION 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * All likes in the system. Note that there is no guarantee of order. 10 | * @gqlQueryField */ 11 | export function likes(args: { 12 | /** @gqlAnnotate max(foo: 10) */ 13 | first?: Int | null; 14 | }): string { 15 | return "hello"; 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnEnum.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on ENUM 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * @gqlEnum 10 | * @gqlAnnotate max(foo: 10) 11 | */ 12 | type MyEnum = "A" | "B"; 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnEnumValue.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on ENUM_VALUE 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * @gqlEnum 10 | */ 11 | enum MyEnum { 12 | /** @gqlAnnotate max(foo: 10) */ 13 | a = "A", 14 | b = "B", 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnFieldDefinition.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on FIELD_DEFINITION 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * All likes in the system. Note that there is no guarantee of order. 10 | * @gqlQueryField 11 | * @gqlAnnotate max(foo: 10) 12 | */ 13 | export function likes(args: { first?: Int | null }): string { 14 | return "hello"; 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnInputFieldDefinition.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on INPUT_FIELD_DEFINITION 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * @gqlInput 10 | */ 11 | type MyType = { 12 | /** @gqlAnnotate max(foo: 10) */ 13 | myField: string; 14 | }; 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnInputObjectType.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on INPUT_OBJECT 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * @gqlInput 10 | * @gqlAnnotate max(foo: 10) 11 | */ 12 | type MyType = { 13 | myField: string; 14 | }; 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnInterface.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on INTERFACE 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * @gqlInterface 10 | * @gqlAnnotate max(foo: 10) 11 | */ 12 | interface MyInterface { 13 | /** @gqlField */ 14 | myField: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnObjectType.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on OBJECT 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * @gqlType 10 | * @gqlAnnotate max(foo: 10) 11 | */ 12 | type MyType = { 13 | /** @gqlField */ 14 | myField: string; 15 | }; 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveOnScalar.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "../../../Types"; 2 | /** 3 | * This is my custom directive. 4 | * @gqlDirective on SCALAR 5 | */ 6 | export function max(args: { foo: Int }) {} 7 | 8 | /** 9 | * @gqlScalar 10 | * @gqlAnnotate max(foo: 10) 11 | */ 12 | type MyScalar = string; 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveUsedWithInvalidArgs.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This is my custom directive. 3 | * @gqlDirective on FIELD_DEFINITION 4 | */ 5 | export function customDirective(args: { foo: string }) {} 6 | 7 | /** 8 | * @gqlQueryField 9 | * @gqlAnnotate customDirective(foo: 10) 10 | */ 11 | export function myQueryField(): string { 12 | return "myQueryField"; 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/directiveWithSyntaxError.invalid.ts: -------------------------------------------------------------------------------- 1 | // Because @myDirective is followed by `(` we assume it's expected to be parsed 2 | // as a directive even though it's not defined. 3 | 4 | /** 5 | * @gqlQueryField 6 | * @gqlAnnotate myDirective(someArg: --oops) 7 | */ 8 | export function myQueryField(): string { 9 | return "myQueryField"; 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/gqlAnnotateOnNonGqlDocblock.ts: -------------------------------------------------------------------------------- 1 | // Because @gqlAnnotate can go on argument definitions which don't have any 2 | // `@gql` tag, we can't report this as an error for now. 3 | 4 | /** 5 | * @gqlAnnotate max(foo: ["a", "b"]) 6 | */ 7 | export function foo() {} 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/undefinedDirectiveWithArgs.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlQueryField 3 | * @gqlAnnotate myDirective(someArg: "someValue") 4 | */ 5 | export function myQueryField(): string { 6 | return "myQueryField"; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/directives/undefinedDirectiveWithoutArgs.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlQueryField 3 | * @myDirective This will be ignored and assumed to be a TypeScript tag 4 | */ 5 | export function myQueryField(): string { 6 | return "myQueryField"; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/DeprecatedEnumVariant.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlEnum */ 8 | enum Enum { 9 | /** 10 | * Valid enum value. 11 | * @deprecated Use something else. 12 | */ 13 | VALID = "VALID", 14 | /** Invalid enum value. */ 15 | INVALID = "INVALID", 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/Enum.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlEnum */ 8 | enum Enum { 9 | VALID = "VALID", 10 | INVALID = "INVALID", 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumFromUnionType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: MyEnum; 5 | } 6 | 7 | /** @gqlEnum */ 8 | type MyEnum = "VALID" | "INVALID"; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumFromUnionTypeNotLiteral.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: MyEnum; 5 | } 6 | 7 | /** @gqlEnum */ 8 | type MyEnum = "VALID" | number; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumFromUnionTypeNotStringLiteral.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: MyEnum; 5 | } 6 | 7 | /** @gqlEnum */ 8 | type MyEnum = "VALID" | 1; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumFromUnionTypeOfStringLiteral.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: MyEnum; 5 | } 6 | 7 | /** @gqlEnum */ 8 | type MyEnum = "VALID"; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumFromUnionTypeWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: MyEnum; 5 | } 6 | 7 | /** 8 | * Hello! 9 | * @gqlEnum 10 | */ 11 | type MyEnum = "VALID" | "INVALID"; 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumNotValidIdentifier.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlEnum */ 8 | export enum Enum { 9 | VALID = "VALID", 10 | INVALID = "NOT AT ALL VALID", 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumValuesDifferentThanNames.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlEnum */ 8 | enum Enum { 9 | ABC = "VALID", 10 | DEF = "INVALID", 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** 8 | * World's best enum. 9 | * 10 | * @gqlEnum 11 | */ 12 | enum Enum { 13 | VALID = "VALID", 14 | INVALID = "INVALID", 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/EnumWithVariantWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlEnum */ 8 | enum Enum { 9 | /** Valid enum value. */ 10 | VALID = "VALID", 11 | /** Invalid enum value. */ 12 | INVALID = "INVALID", 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/ExplicitlyNumericEnum.ts: -------------------------------------------------------------------------------- 1 | /** @gqlEnum */ 2 | enum Enum { 3 | VALID = 1, 4 | INVALID = 2, 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/ImplicitlyNumericEnum.ts: -------------------------------------------------------------------------------- 1 | /** @gqlEnum */ 2 | enum Enum { 3 | VALID, 4 | INVALID, 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/NonNullEnumDefault.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/174 2 | 3 | /** @gqlEnum */ 4 | type GreetingOptions = "Hello" | "Greetings" | "Sup"; 5 | 6 | /** @gqlQueryField */ 7 | export function hello(greeting: GreetingOptions = "Greetings"): string { 8 | return `${greeting} World`; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/NonNullEnumDefaultInInputObject.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/174 2 | 3 | /** @gqlEnum */ 4 | type GreetingOptions = "Hello" | "Greetings" | "Sup"; 5 | 6 | /** @gqlInput */ 7 | type GreetingInput = { 8 | greeting: GreetingOptions; 9 | }; 10 | 11 | /** @gqlQueryField */ 12 | export function hello( 13 | input: GreetingInput = { greeting: "Greetings" }, 14 | ): string { 15 | return `${input.greeting} World`; 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/NonNullPluralEnumDefaults.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/174 2 | 3 | /** @gqlEnum */ 4 | type GreetingOptions = "Hello" | "Greetings" | "Sup"; 5 | 6 | /** @gqlQueryField */ 7 | export function hello( 8 | greeting: GreetingOptions[] = ["Greetings", "Hello"], 9 | ): string { 10 | return `${greeting.join(", ")} World`; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/NonNullTsEnumDefault.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/174 2 | 3 | /** @gqlEnum */ 4 | enum GreetingOptions { 5 | Hello = "HELLO", 6 | // Note that the casing between the variant name and the value is different. 7 | Greetings = "GREETING", 8 | Sup = "SUP", 9 | } 10 | 11 | /** @gqlQueryField */ 12 | export function hello( 13 | greeting: GreetingOptions = GreetingOptions.Greetings, 14 | ): string { 15 | return `${greeting} World`; 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/enums/NonNullTsEnumDefaultStringLiteral.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/174 2 | 3 | /** @gqlEnum */ 4 | enum GreetingOptions { 5 | Hello = "HELLO", 6 | // Note that the casing between the variant name and the value is different. 7 | Greetings = "GREETING", 8 | Sup = "SUP", 9 | } 10 | 11 | /** @gqlQueryField */ 12 | export function hello( 13 | greeting: GreetingOptions = GreetingOptions.Greetings, 14 | ): string { 15 | return `${greeting} World`; 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_interface/addStringFieldToEnum.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlEnum */ 2 | type MyEnum = "Foo" | "Bar"; 3 | 4 | /** @gqlField */ 5 | export function greeting(myEnum: MyEnum): string { 6 | return `Hello ${myEnum}!`; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_interface/addStringFieldToNonGrats.invalid.ts: -------------------------------------------------------------------------------- 1 | type SomeNonGratsType = string; 2 | 3 | /** @gqlField */ 4 | export function greeting(someType: SomeNonGratsType): string { 5 | return `Hello ${someType}!`; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/addDeprecatedField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** 7 | * @gqlField 8 | * @deprecated Because reasons 9 | */ 10 | export function greeting(query: SomeType): string { 11 | return "Hello world!"; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/addFieldWithArguments.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export function greeting(_: SomeType, args: { name: string }): string { 8 | return `Hello ${args.name}!`; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/addFieldWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** 7 | * Best field ever! 8 | * @gqlField 9 | */ 10 | export function greeting(_: SomeType): string { 11 | return "Hello world!"; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/addRenamedFieldToSomeType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField hello */ 7 | export function greeting(_: SomeType): string { 8 | return "Hello world!"; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/addStringFieldToSomeType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export function greeting(_: SomeType): string { 8 | return "Hello world!"; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/defaultExport.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export default function greeting(_: SomeType): string { 8 | return `Hello World`; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsArrowFunctionLet.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export let greeting = (_: SomeType): string => { 8 | return `Hello World`; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsArrowFunctionNotExported.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | const greeting = (_: SomeType): string => { 8 | return `Hello World`; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsArrowFunctionVar.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | var greeting = (_: SomeType): string => { 8 | return `Hello World`; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsExportedArrowFunction.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export const greeting = (_: SomeType): string => { 8 | return `Hello World`; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsExportedArrowFunctionPositionalArgs.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export const greeting = (_: SomeType, name: string): string => { 8 | return `Hello ${name}`; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsExportedAsyncArrowFunction.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export const greeting = async (_: SomeType): Promise => { 8 | return `Hello World`; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsExportedMultipleVariables.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export const greeting = (_: SomeType): string => { 8 | return `Hello World`; 9 | }, 10 | anotherGreeting = (_: SomeType): string => { 11 | return `Hello World`; 12 | }; 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsExportedNothing.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export const greeting; 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/fieldAsExportedNumber.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export const greeting = 10; 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/functionFieldOnTypeDefinedWithInterface.ts: -------------------------------------------------------------------------------- 1 | // https://twitter.com/edvinwennerdahl/status/1748436186840904103 2 | 3 | /** @gqlType */ 4 | interface Cat {} 5 | 6 | /** @gqlField */ 7 | export function catSound(obj: Cat): string { 8 | return "meow"; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/interfaceFirstArgumentType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | foo: string; 5 | } 6 | 7 | /** @gqlInterface */ 8 | interface IFoo { 9 | /** @gqlField */ 10 | bar: string; 11 | } 12 | 13 | /** @gqlField */ 14 | export function greeting(iFoo: IFoo): string { 15 | return "Hello world!"; 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/missingFirstArgument.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export function greeting(/* Without an arg we can't infer the type! */): string { 8 | return "Hello world!"; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/missingFirstArgumentType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export function greeting( 8 | query /* Without an arg type we can't infer the GraphQL type to extend! */, 9 | ): string { 10 | return "Hello world!"; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/nonAliasFirstArgumentType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export function greeting(query: { name: string }): string { 8 | return "Hello world!"; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/nonGQLFirstArgumentType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | class Foo {} 7 | 8 | /** @gqlField */ 9 | export function greeting(query: Foo): string { 10 | return "Hello world!"; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/notExported.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | function greeting(_: Query): string { 8 | return `Hello World`; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/extend_type/optionalModelType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | // No fields 4 | } 5 | 6 | /** @gqlField */ 7 | export function greeting( 8 | // A bit odd that this is optional, but it's fine, since we will always call 9 | // it with a non-null value 10 | q?: SomeType, 11 | ): string { 12 | if (q == null) { 13 | return "Out!"; 14 | } 15 | return "Hello world!"; 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/DeprecatedMethodField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** 4 | * @gqlField 5 | * @deprecated Use something else. 6 | */ 7 | hello(): string { 8 | return "Hello world!"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/DeprecatedPropertyField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** 4 | * @gqlField 5 | * @deprecated Use something else. 6 | */ 7 | hello: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsSetter.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | /** @gqlField */ 4 | set getUser(args: never) { 5 | // 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethod.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | /** @gqlField */ 4 | name: string; 5 | 6 | /** @gqlField */ 7 | static getUser(_: Query): User { 8 | return new User(); 9 | } 10 | } 11 | 12 | /** @gqlType */ 13 | type Query = unknown; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethodInNestedScope.invalid.ts: -------------------------------------------------------------------------------- 1 | function main() { 2 | /** @gqlType */ 3 | class User { 4 | /** @gqlField */ 5 | name: string; 6 | 7 | /** @gqlField */ 8 | static getUser(_: Query): User { 9 | return new User(); 10 | } 11 | } 12 | } 13 | 14 | /** @gqlType */ 15 | type Query = unknown; 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethodInNestedScopeButExported.invalid.ts: -------------------------------------------------------------------------------- 1 | function main() { 2 | /** @gqlType */ 3 | export class User { 4 | /** @gqlField */ 5 | name: string; 6 | 7 | /** @gqlField */ 8 | static getUser(_: Query): User { 9 | return new User(); 10 | } 11 | } 12 | } 13 | 14 | /** @gqlType */ 15 | type Query = unknown; 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethodNotExported.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | /** @gqlField */ 4 | name: string; 5 | 6 | /** @gqlField */ 7 | static getUser(_: Query): User { 8 | return new User(); 9 | } 10 | } 11 | 12 | /** @gqlType */ 13 | type Query = unknown; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethodOnNonDefaultExportUnnamedNonGqlClass.ts: -------------------------------------------------------------------------------- 1 | export class { 2 | /** @gqlField */ 3 | static greet(_: Query): string { 4 | return "Hello, world!"; 5 | } 6 | } 7 | 8 | /** @gqlType */ 9 | type Query = unknown; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethodOnNonGqlClass.ts: -------------------------------------------------------------------------------- 1 | export class SomeClass { 2 | /** @gqlField */ 3 | static greet(_: Query): string { 4 | return "Hello, world!"; 5 | } 6 | } 7 | 8 | /** @gqlType */ 9 | type Query = unknown; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethodOnUnnamedNonGqlClass.ts: -------------------------------------------------------------------------------- 1 | export default class { 2 | /** @gqlField */ 3 | static greet(_: Query): string { 4 | return "Hello, world!"; 5 | } 6 | } 7 | 8 | /** @gqlType */ 9 | type Query = unknown; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticClassMethodWithClassAsDefaultExport.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class User { 3 | /** @gqlField */ 4 | name: string; 5 | 6 | /** @gqlField */ 7 | static getUser(_: Query): User { 8 | return new User(); 9 | } 10 | } 11 | 12 | /** @gqlType */ 13 | type Query = unknown; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldAsStaticMethodOnInterface.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export interface User { 3 | /** @gqlField */ 4 | name: string; 5 | 6 | /** @gqlField */ 7 | static getUser(_: Query): User; 8 | } 9 | 10 | /** @gqlType */ 11 | type Query = unknown; 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldDefinedOnNonGqlType.ts: -------------------------------------------------------------------------------- 1 | class Foo { 2 | /** @gqlField */ 3 | field: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldOnArbitraryParam.ts: -------------------------------------------------------------------------------- 1 | class Foo { 2 | someMethod( 3 | /** @gqlField */ 4 | foo: string, 5 | ): void {} 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FieldTagOnIncorrectNode.ts: -------------------------------------------------------------------------------- 1 | class SomeType { 2 | /** @gqlField */ 3 | constructor() { 4 | // 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/FiledWithUnionOfMultipleTypes.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(): string | boolean { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/GetAcessorField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | get hello(): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/MethodFieldMissingType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | someMethodField() { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/MethodSignatureOnInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface ICarly { 3 | /** @gqlField */ 4 | name(): string; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/MultipleFieldsAsStaticClassMethods.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | /** @gqlField */ 4 | name: string; 5 | 6 | /** @gqlField */ 7 | static getUser(_: Query): User { 8 | return new User(); 9 | } 10 | 11 | /** @gqlField */ 12 | static getUsers(_: Query): User[] { 13 | return [new User()]; 14 | } 15 | } 16 | 17 | /** @gqlType */ 18 | type Query = unknown; 19 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** @gqlField */ 5 | public hello: string, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldBindingPattern.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** @gqlField */ 5 | public [foo]: string, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldDeprecated.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** 5 | * @gqlField 6 | * @deprecated Don't use this 7 | */ 8 | public hello: string, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldNoModifier.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** @gqlField */ 5 | hello: string, 6 | ) { 7 | console.log(hello); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldNoType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** @gqlField */ 5 | public hello, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldReadOnly.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** @gqlField */ 5 | readonly hello: string, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldReadOnlyPrivate.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** 5 | * Greet the world! 6 | * @gqlField 7 | */ 8 | private readonly hello: string, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldRenamed.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** @gqlField hello */ 5 | public foo: string, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ParameterPropertyFieldWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | constructor( 4 | /** 5 | * Greet the world! 6 | * @gqlField 7 | */ 8 | public hello: string, 9 | ) {} 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/PrivateAndProtectedFieldMethods.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | /** @gqlField */ 4 | private greet(): string { 5 | return "Hello"; 6 | } 7 | /** @gqlField */ 8 | protected greet2(): string { 9 | return "Hello"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/PropertyFieldMissingType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | someProp; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/PublicFieldMethod.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | /** @gqlField */ 4 | public greet(): string { 5 | return "Hello"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ReferenceNonGraphQLType.ts: -------------------------------------------------------------------------------- 1 | type SomeUndefienedType = string; 2 | 3 | /** @gqlType */ 4 | class SomeType { 5 | /** @gqlField */ 6 | somePropertyField: SomeUndefienedType; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/ReferenceUndefinedType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | somePropertyField: SomeUndefienedType; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/RenamedField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField greeting */ 4 | somePropertyField: string; 5 | 6 | /** @gqlField salutaion */ 7 | someMethodField(): string { 8 | return "Hello world!"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/RenamedFieldWithArgs.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField greetz */ 4 | hello(args: { greeting: string }): string { 5 | return `${args.greeting} world!`; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/RenamedFieldWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** 4 | * Number 1 greeting. 5 | * 6 | * @gqlField greeting 7 | */ 8 | somePropertyField: string; 9 | 10 | /** 11 | * Number 1 salutation. 12 | * 13 | * @gqlField salutaion 14 | */ 15 | someMethodField(): string { 16 | return "Hello world!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/StringFieldWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** 4 | * Greet the world! 5 | * @gqlField 6 | */ 7 | hello(): string { 8 | return "Hello world!"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_definitions/asyncFunctionFieldNotExported.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlField */ 2 | async function greet(_: Query): Promise { 3 | return "Hello, World!"; 4 | } 5 | 6 | /** @gqlType */ 7 | type Query = unknown; 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/ArrayField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(): Array { 5 | return ["Hello world!"]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/ArrayOfPromises.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | b: Promise[]; 5 | /** @gqlField */ 6 | c: Array>; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/ArrayShorthandField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(): string[] { 5 | return ["Hello world!"]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/ArrayWithNullableItems.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(): Array { 5 | return ["Hello world!", null]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/AsyncPromiseField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | async hello(): Promise { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/BooleanField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | haveBeenGreeted(): boolean { 5 | return false; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/CustomScalar.ts: -------------------------------------------------------------------------------- 1 | /** @gqlScalar */ 2 | type MyString = string; 3 | 4 | /** @gqlType */ 5 | export default class SomeType { 6 | /** @gqlField */ 7 | hello(): MyString { 8 | return "Hello world!"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/DuplicateFields.ts: -------------------------------------------------------------------------------- 1 | // @ts-nocheck 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | hello(): string { 7 | return "Hello world!"; 8 | } 9 | /** @gqlField */ 10 | hello(): Array { 11 | return ["Hello world!"]; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/LinkedField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | async me(): Promise { 5 | return new User(); 6 | } 7 | } 8 | 9 | /** @gqlType */ 10 | class User { 11 | /** @gqlField */ 12 | name(): string { 13 | return "Alice"; 14 | } 15 | /** @gqlField */ 16 | friends(): User[] { 17 | return [new User()]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/LinkedFieldWithTypeArg.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | async me(): Promise> { 5 | return new User(); 6 | } 7 | } 8 | 9 | /** @gqlType */ 10 | class User { 11 | /** @gqlField */ 12 | name(): string { 13 | return "Alice"; 14 | } 15 | /** @gqlField */ 16 | friends(): User[] { 17 | return [new User()]; 18 | } 19 | 20 | other: T; 21 | } 22 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/MaybePromise.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | b: Promise | null; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/OptionalProperty.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello?: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/OptionalStringFieldKillsParentOnException.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** 4 | * @gqlField 5 | * @killsParentOnException 6 | */ 7 | hello(): string | null { 8 | return "Hello world!"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/ParenthesizedType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(): (string | null)[] { 5 | return ["Hello world!"]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/PromiseOfPromise.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | b: Promise>; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/ReadonlyArrayField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(): ReadonlyArray { 5 | return ["Hello world!"]; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/RenamedType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType User */ 2 | class UserResolver { 3 | /** @gqlField */ 4 | name: string; 5 | } 6 | 7 | /** @gqlType */ 8 | class SomeType { 9 | /** @gqlField */ 10 | me: UserResolver; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/RenamedTypeOutOfOrder.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | me: UserResolver; 5 | } 6 | 7 | /** @gqlType User */ 8 | class UserResolver { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/StringField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello(): string { 5 | return "Hello world!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/StringFieldKillsParentOnException.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** 4 | * @gqlField 5 | * @killsParentOnException 6 | */ 7 | hello(): string { 8 | return "Hello world!"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/StringFieldKillsParentOnExceptionWithoutNullableByDefaultEnables.invalid.ts: -------------------------------------------------------------------------------- 1 | // { "nullableByDefault": false } 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** 5 | * @gqlField 6 | * @killsParentOnException 7 | */ 8 | hello(): string { 9 | return "Hello world!"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/UnionField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | class User { 9 | __typename = "User" as const; 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | 14 | /** @gqlType */ 15 | class Entity { 16 | __typename = "Entity" as const; 17 | /** @gqlField */ 18 | description: string; 19 | } 20 | 21 | /** 22 | * @gqlUnion 23 | */ 24 | type Actor = User | Entity; 25 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/non_default_nullable/NonNullablePromise.ts: -------------------------------------------------------------------------------- 1 | // { "nullableByDefault": false } 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello(): Promise { 6 | return Promise.resolve("Hello world!"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/field_values/non_default_nullable/NullablePromise.ts: -------------------------------------------------------------------------------- 1 | // { "nullableByDefault": false } 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello(): Promise { 6 | return Promise.resolve("Hello world!"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/complexMutualReferences.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Foo = { 3 | /** @gqlField */ 4 | someField: Bar; 5 | /** @gqlField */ 6 | baz: Baz; 7 | }; 8 | 9 | /** @gqlType */ 10 | type Bar = { 11 | /** @gqlField */ 12 | anotherField: Foo; 13 | }; 14 | 15 | /** @gqlType */ 16 | type Baz = { 17 | /** @gqlField */ 18 | bazField: Bar; 19 | }; 20 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/defineFieldOnGeneric.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Edge = { 3 | /** @gqlField */ 4 | node: T; 5 | /** @gqlField */ 6 | cursor: string; 7 | }; 8 | 9 | /** @gqlType */ 10 | type Page = { 11 | /** @gqlField */ 12 | title: string; 13 | }; 14 | 15 | /** 16 | * Re-expose title directly on the edge 17 | * @gqlField */ 18 | export function title(edge: Edge): string { 19 | return edge.node.title; 20 | } 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/enumWithGeneric.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlEnum */ 2 | type MyEnum = T | "someValue"; 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/genericInputType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type SomeInput = { 3 | someField: T; 4 | }; 5 | 6 | /** @gqlInput */ 7 | type AnotherInput = { 8 | anotherField: string; 9 | }; 10 | 11 | /** @gqlType */ 12 | class SomeClass { 13 | /** @gqlField */ 14 | someField(args: { someArg: SomeInput }): string { 15 | return args.someArg.someField.anotherField; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/genericInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User implements Friendly { 3 | __typename: "User"; 4 | /** @gqlField */ 5 | name: string; 6 | /** @gqlField */ 7 | to: Dog; 8 | } 9 | 10 | /** @gqlInterface */ 11 | interface Friendly { 12 | /** @gqlField */ 13 | to: T; 14 | } 15 | 16 | /** @gqlType */ 17 | class Dog { 18 | /** @gqlField */ 19 | name: string; 20 | /** @gqlField */ 21 | bestFriend: Friendly; 22 | } 23 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/genericOverArg.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeClass { 3 | /** @gqlField */ 4 | someField(args: { someArg?: T | null }): string { 5 | return "someField"; 6 | } 7 | } 8 | 9 | /** @gqlInput */ 10 | type SomeInput = { 11 | someField: string; 12 | }; 13 | 14 | /** @gqlType */ 15 | type Query = unknown; 16 | 17 | /** @gqlField */ 18 | export function someField(_: Query): SomeClass { 19 | return new SomeClass(); 20 | } 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/genericTypeUsedAsUnionMember.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Page = { 3 | __typename: "Page"; 4 | /** @gqlField */ 5 | name: string; 6 | }; 7 | 8 | /** @gqlType */ 9 | export class Edge { 10 | /** @gqlField */ 11 | node: T; 12 | /** @gqlField */ 13 | cursor: string; 14 | } 15 | 16 | /** @gqlUnion */ 17 | type SomeUnion = Page | Edge; 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/genericTypeUsedAsUnionMemberViaTypeParam.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Page = { 3 | __typename: "Page"; 4 | /** @gqlField */ 5 | foo: SomeUnion>; 6 | }; 7 | 8 | /** @gqlType */ 9 | export class Edge { 10 | /** @gqlField */ 11 | node: T; 12 | } 13 | 14 | /** @gqlUnion */ 15 | type SomeUnion = Page | T; 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/genericTypeUsingClass.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Page = { 3 | /** @gqlField */ 4 | name: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export class Edge { 9 | /** @gqlField */ 10 | node: T; 11 | /** @gqlField */ 12 | cursor: string; 13 | } 14 | 15 | /** @gqlType */ 16 | type Query = unknown; 17 | 18 | /** @gqlField */ 19 | export function createEdge(_: Query): Edge { 20 | return { node: { name: "My Page" }, cursor: "cursor" }; 21 | } 22 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/genericTypeUsingInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Page = { 3 | /** @gqlField */ 4 | name: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | export interface Edge { 9 | /** @gqlField */ 10 | node: T; 11 | /** @gqlField */ 12 | cursor: string; 13 | } 14 | 15 | /** @gqlType */ 16 | type Query = unknown; 17 | 18 | /** @gqlField */ 19 | export function createEdge(_: Query): Edge { 20 | return { node: { name: "My Page" }, cursor: "cursor" }; 21 | } 22 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/missingGqlGenericTypeArg.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Edge = { 3 | /** @gqlField */ 4 | node: T; 5 | /** @gqlField */ 6 | cursor: string; 7 | }; 8 | 9 | /** @gqlType */ 10 | export type PageConnection = { 11 | /** @gqlField */ 12 | edges: Edge[]; 13 | }; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/passOuptutTypeToInputType.input.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | export type SomeInput = { 3 | someField: T; 4 | }; 5 | 6 | /** @gqlInput */ 7 | type AnotherInput = { 8 | anotherField: string; 9 | }; 10 | 11 | /** @gqlType */ 12 | class SomeClass { 13 | /** @gqlField */ 14 | someField(args: { someArg: SomeInput }): string { 15 | return args.someArg.someField.someField(args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/referencingMethodGeneric.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Query = unknown; 3 | 4 | /** @gqlField */ 5 | export function greeting(_: Query): T { 6 | return null as any; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/result.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Err = { 3 | __typename: "Err"; 4 | /** @gqlField */ 5 | message: string; 6 | }; 7 | 8 | /** @gqlUnion */ 9 | type Result = T | Err; 10 | 11 | /** @gqlType */ 12 | export type Page = { 13 | __typename: "Page"; 14 | /** @gqlField */ 15 | name: string; 16 | }; 17 | 18 | /** @gqlType */ 19 | export type SomeType = { 20 | /** @gqlField */ 21 | pageResult: Result; 22 | }; 23 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/scalarPassedAsGenericArg.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Wrapper = { 3 | /** @gqlField */ 4 | value: T; 5 | }; 6 | 7 | /** @gqlType */ 8 | type OtherType = { 9 | /** @gqlField */ 10 | wrapper: Wrapper; 11 | }; 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/scalarPassedAsNonGqlGenericArg.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Wrapper = { 3 | /** @gqlField */ 4 | value: string; 5 | }; 6 | 7 | /** @gqlType */ 8 | type OtherType = { 9 | /** @gqlField */ 10 | wrapper: Wrapper; 11 | }; 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/scalarWithGeneric.ts: -------------------------------------------------------------------------------- 1 | // T is not inspected by Grats, so this is fine. 2 | /** @gqlScalar */ 3 | type MyScalar = T; 4 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/todo/genericInterfaceFromTypeParam.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User implements Friendly { 3 | __typename: "User"; 4 | /** @gqlField */ 5 | name: string; 6 | } 7 | 8 | /** @gqlInterface */ 9 | interface Friendly { 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | 14 | /** @gqlType */ 15 | class Dog { 16 | /** @gqlField */ 17 | name: string; 18 | /** @gqlField */ 19 | bestFriend: User; 20 | } 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/todo/genericTypeImplementsInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User implements Friendly { 3 | __typename: "User"; 4 | /** @gqlField */ 5 | name: string; 6 | 7 | /** @gqlField */ 8 | friend: T; 9 | } 10 | 11 | /** @gqlInterface */ 12 | interface Friendly { 13 | /** @gqlField */ 14 | name: string; 15 | } 16 | 17 | /** @gqlType */ 18 | class Dog { 19 | /** @gqlField */ 20 | name: string; 21 | /** @gqlField */ 22 | bestFriend: User; 23 | } 24 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/todo/genericTypeMemberOfUnion.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | __typename: "User"; 4 | /** @gqlField */ 5 | name: string; 6 | 7 | /** @gqlField */ 8 | friend: T; 9 | } 10 | 11 | /** @gqUnion */ 12 | type Friendly = User; 13 | 14 | /** @gqlType */ 15 | class Dog { 16 | /** @gqlField */ 17 | name: string; 18 | } 19 | -------------------------------------------------------------------------------- /src/tests/fixtures/generics/undefinedTypeUsedAsGenericTypeArg.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Edge = { 3 | /** @gqlField */ 4 | node: T; 5 | /** @gqlField */ 6 | cursor: string; 7 | }; 8 | 9 | /** @gqlType */ 10 | export type PageConnection = { 11 | /** @gqlField */ 12 | edges: Edge[]; 13 | }; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/headers/customHeaders.ts: -------------------------------------------------------------------------------- 1 | // {"schemaHeader": "# Generated SDL", "tsSchemaHeader": "// Generated TS"} 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/headers/multilineHeader.ts: -------------------------------------------------------------------------------- 1 | // {"schemaHeader": ["# Generated SDL\n", "# multi-line"], "tsSchemaHeader": ["// Generated TS\n", "// multi-line"]} 2 | /** @gqlType */ 3 | export default class SomeType { 4 | /** @gqlField */ 5 | hello: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfDeprecated.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | * @deprecated Don't use this any more 4 | */ 5 | export type Greeting = { firstName: string } | { lastName: string }; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfFieldIsNullable.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = { firstName: string } | { lastName: string | null }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfFieldIsOptional.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = { firstName: string } | { lastName?: string }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfFieldMissingTypeAnnotation.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = { firstName: string } | { lastName }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfFieldTypeList.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = { firstName: string } | { lastName: Array }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfFieldTypeListOfNullable.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = 5 | | { firstName: string } 6 | | { lastName: Array }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfFieldTypeNotGraphQL.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = { firstName: string } | { lastName: Set }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfMemberHasMultipleFields.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = 5 | | { firstName: string } 6 | | { lastName: string; nickName: string }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfMemberHasNoField.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | type Greeting = { firstName: string } | {}; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfUnionMemberNotLiteral.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = string | { name: string }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfWithFieldDescription.ts: -------------------------------------------------------------------------------- 1 | // Known issue, descriptions are not parsed? 2 | 3 | /** 4 | * @gqlInput 5 | */ 6 | export type Greeting = 7 | /** First Name */ 8 | | { firstName: string } 9 | /** Last Name */ 10 | | { lastName: string }; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfWithFieldDescriptionInsideObj.ts: -------------------------------------------------------------------------------- 1 | // Known issue, descriptions are not parsed? 2 | 3 | /** 4 | * @gqlInput 5 | */ 6 | export type Greeting = 7 | | { 8 | /** First Name */ 9 | firstName: string; 10 | } 11 | | { 12 | /** Last Name */ 13 | lastName: string; 14 | }; 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/oneOfWithTypeDescription.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A popular way to greet someone. 3 | * 4 | * @gqlInput 5 | */ 6 | export type Greeting = { firstName: string } | { lastName: string }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/simpleOneOf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type Greeting = { firstName: string } | { lastName: string }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_type_one_of/simpleOneOfDeprecatedTag.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | * @oneOf 4 | */ 5 | export type Greeting = { firstName: string } | { lastName: string }; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/ContextReferencedInInputType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlContext */ 2 | type SomeType = { 3 | hello: string; 4 | }; 5 | 6 | /** @gqlInput */ 7 | type MyInputType = { 8 | someField: SomeType; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/DeprecatedInputType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** 8 | * Check out this great input! 9 | * @gqlInput 10 | * @deprecated This old thing? 11 | */ 12 | type MyInputType = { 13 | someField: string; 14 | }; 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlInput */ 8 | type MyInputType = { 9 | someField: string; 10 | }; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | interface MyInputType { 3 | someField: string; 4 | } 5 | 6 | /** @gqlType */ 7 | class User { 8 | /** @gqlField */ 9 | myField(args: { input: MyInputType }): string { 10 | return args.input.someField; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeInterfaceFunction.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | interface MyInputType { 3 | // TypeScript lets you define functions using interfaces, 4 | // but that makes no sense as a GraphQL input type. 5 | (arg: string): string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeInterfaceMethod.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | interface MyInputType { 3 | someMethod(): string; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeInterfaceOptionalField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | interface MyInputType { 3 | someField?: string; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeInterfacePromiseField.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | interface MyInputType { 3 | someMethod: Promise; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeInterfacePromiseField.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlInput */ 5 | interface MyInputType { 6 | someMethod: Promise; 7 | } 8 | 9 | ----------------- 10 | OUTPUT 11 | ----------------- 12 | src/tests/fixtures/input_types/InputTypeInterfacePromiseField.invalid.ts:3:15 - error: `Promise` is not a valid as an input type. 13 | 14 | 3 someMethod: Promise; 15 | ~~~~~~~~~~~~~~~ 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeMergedInterface.invalid.ts: -------------------------------------------------------------------------------- 1 | interface MyInputType { 2 | secretConfusingField: string; 3 | } 4 | 5 | /** @gqlInput */ 6 | interface MyInputType { 7 | someField: string; 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeOptionalField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlInput */ 8 | type MyInputType = { 9 | someField?: string; 10 | }; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeReferencingOutputType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | someField(args: { input: MyInputType }): string; 5 | } 6 | 7 | /** @gqlInput */ 8 | type MyInputType = { 9 | someField: SomeType; 10 | }; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeReturnedFromField.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlType */ 8 | class MyType { 9 | /** @gqlField */ 10 | someField(): MyInputType; 11 | } 12 | 13 | /** @gqlInput */ 14 | type MyInputType = { 15 | someField: MyType; 16 | }; 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeWithDeprecatedField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlInput */ 8 | type MyInputType = { 9 | /** Sweet field! 10 | * @deprecated Sweet, but stale 11 | */ 12 | someField?: string; 13 | }; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeWithDeprecatedRequiredField.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlInput */ 8 | type MyInputType = { 9 | /** Sweet field! 10 | * @deprecated Sweet, but stale 11 | */ 12 | someField: string; 13 | }; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** 8 | * Check out this great input! 9 | * @gqlInput 10 | */ 11 | type MyInputType = { 12 | someField: string; 13 | }; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/InputTypeWithFieldDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlInput */ 8 | type MyInputType = { 9 | /** Sweet field! */ 10 | someField: string; 11 | }; 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/RenamedInputType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlInput OtherName */ 8 | type MyInputType = { 9 | someField: string; 10 | }; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/input_types/inputFieldWithGqlField.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | type Foo = { 3 | /** @gqlField */ 4 | name: string; 5 | }; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/FieldReturnsInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me(): IPerson { 5 | return new User(); 6 | } 7 | } 8 | 9 | /** @gqlInterface Person */ 10 | interface IPerson { 11 | /** @gqlField */ 12 | name: string; 13 | } 14 | 15 | /** @gqlType */ 16 | class User implements IPerson { 17 | __typename = "User" as const; 18 | /** @gqlField */ 19 | name: string; 20 | } 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/IgnoresExtendsClause.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me(): User { 5 | return new User(); 6 | } 7 | } 8 | 9 | class Person { 10 | name: string; 11 | } 12 | 13 | /** @gqlInterface */ 14 | interface Actor { 15 | /** @gqlField */ 16 | name: string; 17 | } 18 | 19 | /** @gqlType */ 20 | class User extends Person implements Actor { 21 | __typename = "User" as const; 22 | /** @gqlField */ 23 | name: string; 24 | } 25 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/ImplementsInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me(): User { 5 | return new User(); 6 | } 7 | } 8 | 9 | /** @gqlInterface */ 10 | interface Person { 11 | /** @gqlField */ 12 | name: string; 13 | } 14 | 15 | /** @gqlType */ 16 | class User implements Person { 17 | __typename = "User" as const; 18 | /** @gqlField */ 19 | name: string; 20 | } 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/ImplementsRenamedInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface Person */ 2 | interface DONT_USE_THIS { 3 | /** @gqlField */ 4 | name: string; 5 | } 6 | 7 | /** @gqlType */ 8 | class User implements DONT_USE_THIS { 9 | __typename = "User" as const; 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceExtendsInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface Node */ 2 | interface GqlNode { 3 | /** @gqlField */ 4 | id: string; 5 | } 6 | 7 | /** @gqlInterface */ 8 | interface Person { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | 13 | /** @gqlInterface */ 14 | interface Actor extends GqlNode, Person { 15 | /** @gqlField */ 16 | id: string; 17 | /** @gqlField */ 18 | name: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceFieldWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me(): User { 5 | return new User(); 6 | } 7 | } 8 | 9 | /** @gqlInterface */ 10 | interface IPerson { 11 | /** 12 | * The person's name 13 | * @gqlField 14 | */ 15 | name: string; 16 | } 17 | 18 | /** @gqlType */ 19 | class User implements IPerson { 20 | __typename = "User" as const; 21 | /** @gqlField */ 22 | name: string; 23 | } 24 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceImplementsInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface Node */ 2 | interface GqlNode { 3 | /** @gqlField */ 4 | id: string; 5 | } 6 | 7 | /** @gqlInterface */ 8 | interface Person { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | 13 | /** @gqlInterface */ 14 | interface Actor extends GqlNode, Person { 15 | /** @gqlField */ 16 | id: string; 17 | /** @gqlField */ 18 | name: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceMergedIntoClass.invalid.ts: -------------------------------------------------------------------------------- 1 | class Foo { 2 | someField: number; 3 | } 4 | 5 | /** @gqlInterface */ 6 | interface Foo { 7 | /** @gqlField */ 8 | id: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceMergedIntoNode.invalid.ts: -------------------------------------------------------------------------------- 1 | // { "tsVersion": "5.0.2" } 2 | // Note: Node is a built in class. 3 | /** @gqlInterface */ 4 | interface Node { 5 | /** @gqlField */ 6 | id: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceMergedIntoObject.invalid.ts: -------------------------------------------------------------------------------- 1 | declare const Foo: { 2 | prototype: Foo; 3 | new (): Foo; 4 | }; 5 | 6 | /** @gqlInterface */ 7 | interface Foo { 8 | /** @gqlField */ 9 | id: string; 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceMissingFields.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface SomeType {} 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceWithCustomName.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me(): User { 5 | return new User(); 6 | } 7 | } 8 | 9 | /** @gqlInterface Person */ 10 | interface IPerson { 11 | /** @gqlField */ 12 | name: string; 13 | } 14 | 15 | /** @gqlType */ 16 | class User implements IPerson { 17 | __typename = "User" as const; 18 | /** @gqlField */ 19 | name: string; 20 | } 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/InterfaceWithDeprecatedField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me(): User { 5 | return new User(); 6 | } 7 | } 8 | 9 | /** @gqlInterface */ 10 | interface IPerson { 11 | /** @gqlField 12 | * @deprecated Not used anymore 13 | */ 14 | name?: string; 15 | } 16 | 17 | /** @gqlType */ 18 | class User implements IPerson { 19 | __typename = "User" as const; 20 | /** @gqlField */ 21 | name?: string; 22 | } 23 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/MergedInterfaces.ts: -------------------------------------------------------------------------------- 1 | import { ID } from "../../../types"; 2 | 3 | /** @gqlType */ 4 | export default class SomeType { 5 | /** @gqlField */ 6 | me(): Node { 7 | throw new Error("Not implemented"); 8 | } 9 | } 10 | 11 | interface Node { 12 | id: ID; 13 | } 14 | 15 | /** @gqlInterface */ 16 | interface Node { 17 | /** @gqlField */ 18 | id: string; 19 | } 20 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/TagAttachedToWrongNode.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface Person */ 2 | function Foo() {} 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/TagAttachedToWrongNode.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlInterface Person */ 5 | function Foo() {} 6 | 7 | ----------------- 8 | OUTPUT 9 | ----------------- 10 | src/tests/fixtures/interfaces/TagAttachedToWrongNode.ts:1:5 - error: `@gqlInterface` can only be used on interface declarations. e.g. `interface MyInterface {}` 11 | 12 | 1 /** @gqlInterface Person */ 13 | ~~~~~~~~~~~~~~~~~~~~~ 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/extendInterfaceWithNonGqlType.ts: -------------------------------------------------------------------------------- 1 | interface IThing { 2 | name: string; 3 | } 4 | 5 | /** 6 | * @gqlInterface 7 | */ 8 | export interface IPerson extends IThing { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/interfaces/tag/ImplementsTagWithoutTypeOrInterface.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlImplements Node */ 2 | function hello() { 3 | return "world"; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/fieldOnScalar.invalid.ts: -------------------------------------------------------------------------------- 1 | // Locate: Date.name 2 | /** @gqlScalar */ 3 | type Date = string; 4 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/fieldOnScalar.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: Date.name 5 | /** @gqlScalar */ 6 | type Date = string; 7 | 8 | ----------------- 9 | OUTPUT 10 | ----------------- 11 | Cannot locate field `name` on type `Date`. Only object types, interfaces, and input objects have fields. -------------------------------------------------------------------------------- /src/tests/fixtures/locate/inputType.ts: -------------------------------------------------------------------------------- 1 | // Locate: User 2 | /** @gqlInput */ 3 | type User = { 4 | name: string; 5 | }; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/inputType.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: User 5 | /** @gqlInput */ 6 | type User = { 7 | name: string; 8 | }; 9 | 10 | ----------------- 11 | OUTPUT 12 | ----------------- 13 | src/tests/fixtures/locate/inputType.ts:3:6 - error: Located here 14 | 15 | 3 type User = { 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/inputTypeField.ts: -------------------------------------------------------------------------------- 1 | // Locate: User.name 2 | /** @gqlInput */ 3 | type User = { 4 | name: string; 5 | }; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/inputTypeField.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: User.name 5 | /** @gqlInput */ 6 | type User = { 7 | name: string; 8 | }; 9 | 10 | ----------------- 11 | OUTPUT 12 | ----------------- 13 | src/tests/fixtures/locate/inputTypeField.ts:4:3 - error: Located here 14 | 15 | 4 name: string; 16 | ~~~~ 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/interface.ts: -------------------------------------------------------------------------------- 1 | // Locate: Person 2 | /** @gqlInterface */ 3 | interface Person { 4 | /** @gqlField */ 5 | name: string; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/interface.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: Person 5 | /** @gqlInterface */ 6 | interface Person { 7 | /** @gqlField */ 8 | name: string; 9 | } 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | src/tests/fixtures/locate/interface.ts:3:11 - error: Located here 15 | 16 | 3 interface Person { 17 | ~~~~~~ 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/malformedEntitySyntax.invalid.ts: -------------------------------------------------------------------------------- 1 | // Locate: User->name 2 | /** @gqlType */ 3 | type User = { 4 | /** @gqlField */ 5 | name: string; 6 | }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/malformedEntitySyntax.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: User->name 5 | /** @gqlType */ 6 | type User = { 7 | /** @gqlField */ 8 | name: string; 9 | }; 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | Invalid entity name: `User->name`. Expected `ParentType` or `ParentType.fieldName`. -------------------------------------------------------------------------------- /src/tests/fixtures/locate/notFoundField.invalid.ts: -------------------------------------------------------------------------------- 1 | // Locate: User.not_a_field 2 | /** @gqlType */ 3 | type User = { 4 | /** @gqlField */ 5 | name: string; 6 | }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/notFoundField.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: User.not_a_field 5 | /** @gqlType */ 6 | type User = { 7 | /** @gqlField */ 8 | name: string; 9 | }; 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | Cannot locate field `not_a_field` on type `User`. -------------------------------------------------------------------------------- /src/tests/fixtures/locate/notFoundType.invalid.ts: -------------------------------------------------------------------------------- 1 | // Locate: WhoopsNotARealType 2 | /** @gqlType */ 3 | type User = { 4 | /** @gqlField */ 5 | name: string; 6 | }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/notFoundType.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: WhoopsNotARealType 5 | /** @gqlType */ 6 | type User = { 7 | /** @gqlField */ 8 | name: string; 9 | }; 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | Cannot locate type `WhoopsNotARealType`. -------------------------------------------------------------------------------- /src/tests/fixtures/locate/type.ts: -------------------------------------------------------------------------------- 1 | // Locate: User 2 | /** @gqlType */ 3 | type User = { 4 | /** @gqlField */ 5 | name: string; 6 | }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/type.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: User 5 | /** @gqlType */ 6 | type User = { 7 | /** @gqlField */ 8 | name: string; 9 | }; 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | src/tests/fixtures/locate/type.ts:3:6 - error: Located here 15 | 16 | 3 type User = { 17 | ~~~~ 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/typeField.ts: -------------------------------------------------------------------------------- 1 | // Locate: User.name 2 | /** @gqlType */ 3 | type User = { 4 | /** @gqlField */ 5 | name: string; 6 | }; 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/locate/typeField.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | // Locate: User.name 5 | /** @gqlType */ 6 | type User = { 7 | /** @gqlField */ 8 | name: string; 9 | }; 10 | 11 | ----------------- 12 | OUTPUT 13 | ----------------- 14 | src/tests/fixtures/locate/typeField.ts:5:3 - error: Located here 15 | 16 | 5 name: string; 17 | ~~~~ 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/regression/fieldFollowedByDeprecated.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | /** 4 | * @gqlField name 5 | * @deprecated 6 | */ 7 | graphQLName(): string { 8 | return "Sup"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ClassMethodWithContextValue.ts: -------------------------------------------------------------------------------- 1 | /** @gqlContext */ 2 | type GratsContext = { 3 | greeting: string; 4 | }; 5 | 6 | /** @gqlType */ 7 | export class SomeType { 8 | /** @gqlField */ 9 | greeting(ctx: GratsContext): string { 10 | return ctx.greeting; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ClassMethodWithContextValueExported.ts: -------------------------------------------------------------------------------- 1 | /** @gqlContext */ 2 | export type GratsContext = { 3 | greeting: string; 4 | }; 5 | 6 | /** @gqlType */ 7 | export class SomeType { 8 | /** @gqlField */ 9 | greeting(ctx: GratsContext): string { 10 | return ctx.greeting; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ClassMethodWithContextValueInArgsPos.invalid.ts: -------------------------------------------------------------------------------- 1 | type GratsContext = { 2 | greeting: string; 3 | }; 4 | 5 | /** @gqlType */ 6 | export class SomeType { 7 | /** @gqlField */ 8 | greeting(ctx: GratsContext): string { 9 | return ctx.greeting; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueBeforeArgs.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(ctx: SomeOtherType, args: { fallbackGreeting: string }): string { 5 | return ctx.greeting ?? args.fallbackGreeting; 6 | } 7 | } 8 | 9 | /** @gqlContext */ 10 | type SomeOtherType = { greeting?: string }; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueMissingTypeAnnotation.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(ctx): string { 5 | return ctx.greeting; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueOptional.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(ctx?: SomeOtherType): string { 5 | // This is fine since Grats will always pass ctx. It's fine for 6 | // the resolver to _also_ work _without_ ctx, as long as it's 7 | // safe for Grats to pass ctx. 8 | return ctx?.greeting ?? "Hello, World!"; 9 | } 10 | } 11 | 12 | /** @gqlContext */ 13 | type SomeOtherType = { greeting: string }; 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueReadTwice.ts: -------------------------------------------------------------------------------- 1 | // No valid reason to do this, but just asserting that it works, since it happens to. 2 | 3 | /** @gqlType */ 4 | export class SomeType { 5 | /** @gqlField */ 6 | greeting(ctx: SomeOtherType, alsoContext: SomeOtherType): string { 7 | return ctx.greeting ?? "Hello, world!"; 8 | } 9 | } 10 | 11 | /** @gqlContext */ 12 | type SomeOtherType = { greeting?: string }; 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueSpread.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(...ctx: SomeOtherType[]): string { 5 | return ctx[0].greeting; 6 | } 7 | } 8 | 9 | /** @gqlContext */ 10 | type SomeOtherType = { greeting: string }; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueTypeNotDefined.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(ctx: ThisIsNeverDefined): string { 5 | return ctx.greeting; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueTypedAsAny.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(ctx: any): string { 5 | return ctx.greeting; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueTypedAsNever.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(ctx: never): string { 5 | return ctx.greeting; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/ContextValueTypedAsUnknown.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class SomeType { 3 | /** @gqlField */ 4 | greeting(ctx: unknown): string { 5 | return ctx.greeting; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/FunctionWithContextValue.ts: -------------------------------------------------------------------------------- 1 | /** @gqlContext */ 2 | type GratsContext = { 3 | greeting: string; 4 | }; 5 | 6 | /** @gqlType */ 7 | export class User {} 8 | 9 | /** @gqlField */ 10 | export function greeting(_: User, ctx: GratsContext): string { 11 | return ctx.greeting; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_context/MultipleClassMethodsReferencingContextValue.ts: -------------------------------------------------------------------------------- 1 | /** @gqlContext */ 2 | type GratsContext = { 3 | greeting: string; 4 | }; 5 | 6 | /** @gqlType */ 7 | export class SomeType { 8 | /** @gqlField */ 9 | greeting(ctx: GratsContext): string { 10 | return ctx.greeting; 11 | } 12 | 13 | /** @gqlField */ 14 | alsoGreeting(ctx: GratsContext): string { 15 | return ctx.greeting; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_info/ClassMethodWithInfoValue.ts: -------------------------------------------------------------------------------- 1 | import { GqlInfo } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export class SomeType { 5 | /** @gqlField greeting */ 6 | greetz(info: GqlInfo): string { 7 | return "Hello"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_info/FunctionWithInfoValue.ts: -------------------------------------------------------------------------------- 1 | import { GqlInfo } from "../../../Types"; 2 | 3 | /** @gqlField */ 4 | export function greetz(_: Query, info: GqlInfo): string { 5 | return "Hello"; 6 | } 7 | 8 | /** @gqlType */ 9 | type Query = unknown; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/resolver_info/StaticMethodWithInfoValue.ts: -------------------------------------------------------------------------------- 1 | import { GqlInfo } from "../../../Types"; 2 | 3 | /** @gqlType */ 4 | export class SomeType { 5 | /** @gqlField */ 6 | someField: string; 7 | 8 | /** @gqlField greeting */ 9 | static greetz(_: Query, info: GqlInfo): string { 10 | return "Hello"; 11 | } 12 | } 13 | 14 | /** @gqlType */ 15 | type Query = unknown; 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/semantic_nullability/semanticNonNull.ts: -------------------------------------------------------------------------------- 1 | // { "strictSemanticNullability": true } 2 | 3 | /** @gqlType */ 4 | export class User { 5 | /** @gqlField */ 6 | name(): string { 7 | if (Math.random() < 0.5) { 8 | throw new Error("Stuff happens..."); 9 | } 10 | return "Alice"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/semantic_nullability/semanticNull.ts: -------------------------------------------------------------------------------- 1 | // { "strictSemanticNullability": true } 2 | 3 | /** @gqlType */ 4 | export class User { 5 | /** @gqlField */ 6 | name(): string | null { 7 | if (Math.random() < 0.25) { 8 | return null; 9 | } 10 | if (Math.random() < 0.5) { 11 | throw new Error("Stuff happens..."); 12 | } 13 | return "Alice"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/subscriptions/InputTypeWithAsyncIterable.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInput */ 2 | export type NotSubscription = { 3 | greetings: AsyncIterable; 4 | }; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/subscriptions/InterfaceWithAsyncIterable.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | export interface NotSubscription { 3 | /** @gqlField */ 4 | greetings(): AsyncIterable; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/subscriptions/SubscriptionClassWithAsyncIterable.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class Subscription { 3 | /** @gqlField */ 4 | async *greetings(): AsyncIterable { 5 | yield "Hello"; 6 | yield "World"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/todo/EnumFromUnionTypeWithVariantWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | hello: MyEnum; 5 | } 6 | 7 | /** @gqlEnum */ 8 | type MyEnum = 9 | /** VALIDATED! */ 10 | | "VALID" 11 | /** INVALIDATED! */ 12 | | "INVALID"; 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/todo/RedefineBuiltinScalar.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlScalar String */ 2 | type MyUrl = string; 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/todo/RedefineBuiltinScalar.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlScalar String */ 5 | type MyUrl = string; 6 | 7 | ----------------- 8 | OUTPUT 9 | ----------------- 10 | -- SDL -- 11 | 12 | -- TypeScript -- 13 | import { GraphQLSchema } from "graphql"; 14 | export function getSchema(): GraphQLSchema { 15 | return new GraphQLSchema({ 16 | types: [] 17 | }); 18 | } 19 | -------------------------------------------------------------------------------- /src/tests/fixtures/todo/userExample.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type SomeType = {}; 3 | 4 | /** @gqlField */ 5 | export function me(_: SomeType): User { 6 | return { firstName: "John", lastName: "Doe" }; 7 | } 8 | 9 | /** @gqlType */ 10 | type User = { 11 | /** @gqlField */ 12 | firstName: string; 13 | /** @gqlField */ 14 | lastName: string; 15 | }; 16 | 17 | /** @gqlField */ 18 | export function fullName(user: User): string { 19 | return `${user.firstName} ${user.lastName}`; 20 | } 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/top_level_fields/queryField.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function greeting(): string { 3 | return "Hello world"; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/top_level_fields/queryFieldOnMethod.ts: -------------------------------------------------------------------------------- 1 | export class SomeNonGraphQLClass { 2 | /** @gqlQueryField */ 3 | greeting(): string { 4 | return "Hello world"; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/top_level_fields/queryFieldOnStaticMethod.ts: -------------------------------------------------------------------------------- 1 | export class SomeNonGraphQLClass { 2 | /** @gqlQueryField */ 3 | static greeting(): string { 4 | return "Hello world"; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/top_level_fields/queryFieldRenamed.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField greeting */ 2 | export function greetz(): string { 3 | return "Hello world"; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/top_level_fields/queryFieldWithExplicitlyDefinedQuery.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function greeting(): string { 3 | return "Hello world"; 4 | } 5 | 6 | /** 7 | * I might want to explicitly define a type here to provide a description. 8 | * 9 | * @gqlType */ 10 | export type Query = unknown; 11 | -------------------------------------------------------------------------------- /src/tests/fixtures/top_level_fields/queryFieldWithFirstArgParentType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Query = unknown; 3 | 4 | /** @gqlQueryField */ 5 | export function greeting(_: Query): string { 6 | return "Hello world"; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/top_level_fields/rootSubscriptionFieldNotAsyncIterable.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlSubscriptionField */ 2 | export function foo(): string { 3 | return "Hello"; 4 | } 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/ClassImplementsNonGqlInterface.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The root of all evil. 3 | * @gqlType 4 | */ 5 | export default class User implements IPerson { 6 | /** @gqlField */ 7 | hello: string; 8 | } 9 | 10 | interface IPerson { 11 | hello: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/ClassMissingFields.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType {} 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/ClassWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The root of all evil. 3 | * 4 | * @gqlType 5 | */ 6 | export default class SomeType { 7 | /** @gqlField */ 8 | hello: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/ClassWithDescriptionAndCustomName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The root of all evil. 3 | * 4 | * @gqlType SomeType 5 | */ 6 | export default class NotQuery { 7 | /** @gqlField */ 8 | hello: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/ClassWithoutAName.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType 3 | */ 4 | export default class { 5 | /** @gqlField */ 6 | hello(): string { 7 | return "Hello world!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/QueryAsClass.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class Query { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/RenamedType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType SomeType 3 | */ 4 | class MyClass { 5 | /** @gqlField */ 6 | hello(): string { 7 | return "Hello world!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/RenamedTypeHasDash.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType Some-Type 3 | */ 4 | class MyClass { 5 | /** @gqlField */ 6 | hello(): string { 7 | return "Hello world!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/RenamedTypeNewLine.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType 3 | * 4 | * SomeType 5 | */ 6 | class MyClass { 7 | /** @gqlField */ 8 | hello(): string { 9 | return "Hello world!"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/RenamedTypeStartsWithNumber.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType 1SomeType 3 | */ 4 | class MyClass { 5 | /** @gqlField */ 6 | hello(): string { 7 | return "Hello world!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/RenamedTypeWithoutClassName.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType SomeType 3 | */ 4 | export default class { 5 | /** @gqlField */ 6 | hello(): string { 7 | return "Hello world!"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/TagAttachedToWrongNode.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | function MyFunc() {} 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/TagAttachedToWrongNode.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlType */ 5 | function MyFunc() {} 6 | 7 | ----------------- 8 | OUTPUT 9 | ----------------- 10 | src/tests/fixtures/type_definitions/TagAttachedToWrongNode.ts:1:5 - error: `@gqlType` can only be used on class, interface or type declarations. e.g. `class MyType {}` 11 | 12 | 1 /** @gqlType */ 13 | ~~~~~~~~~ 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/TypeFromClassDefinitionImplementsInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface Person { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** @gqlType */ 8 | export default class User implements Person { 9 | readonly __typename = "User" as const; 10 | /** @gqlField */ 11 | hello: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions/TypeFromClassDefinitionImplementsInterfaceWithDeprecatedTag.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface Person { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | 7 | /** 8 | * @gqlType 9 | * @gqlImplements Person 10 | */ 11 | export default class User { 12 | readonly __typename = "User" as const; 13 | /** @gqlField */ 14 | hello: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/AliasIsArrayNotLiteral.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export type SomeType = { 3 | hello: string; 4 | }[]; 5 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/AliasIsNumberNotLiteral.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export type SomeType = 10; 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/AliasOfUnknownDefinesType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export type SomeType = unknown; 3 | 4 | /** @gqlField */ 5 | export function greeting(_: SomeType): string { 6 | return "Hello world"; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/AliasType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export type SomeType = { 3 | /** @gqlField */ 4 | hello: string; 5 | }; 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/AliasTypeImplementsInterface.invalid.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType 3 | * @gqlImplements Person 4 | */ 5 | export type User = { 6 | __typename: "User"; 7 | /** @gqlField */ 8 | name: string; 9 | }; 10 | 11 | /** @gqlInterface */ 12 | interface Person { 13 | /** @gqlField */ 14 | name: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/AliasWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The root of all evil. 3 | * 4 | * @gqlType 5 | */ 6 | export type SomeType = { 7 | /** @gqlField */ 8 | hello: string; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/AliasWithDescriptionAndCustomName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The root of all evil. 3 | * 4 | * @gqlType SomeType 5 | */ 6 | export type NotQuery = { 7 | /** @gqlField */ 8 | hello: string; 9 | }; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/QueryAsAliasOfObject.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Query = {}; 3 | 4 | /** @gqlField */ 5 | export function foo(_: Query): string { 6 | return "foo"; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/QueryAsAliasOfUndefined.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Query = undefined; 3 | 4 | /** @gqlField */ 5 | export function foo(_: Query): string { 6 | return "foo"; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/QueryAsAliasOfUnknown.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type Query = unknown; 3 | 4 | /** @gqlField */ 5 | export function foo(_: Query): string { 6 | return "foo"; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_alias/RenamedType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType SomeType 3 | */ 4 | type MyAlias = { 5 | /** @gqlField */ 6 | hello: string; 7 | }; 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/InterfaceType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default interface SomeType { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/InterfaceTypeExtendsGqlInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface Person { 3 | /** @gqlField */ 4 | name: string; 5 | } 6 | 7 | /** @gqlType */ 8 | export interface User extends Person { 9 | __typename: "User"; 10 | 11 | /** @gqlField */ 12 | name: string; 13 | } 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/InterfaceTypeExtendsGqlInterfaceWithDeprecatedTag.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface Person { 3 | /** @gqlField */ 4 | name: string; 5 | } 6 | 7 | /** 8 | * @gqlType 9 | * @gqlImplements Person 10 | */ 11 | export interface User { 12 | __typename: "User"; 13 | 14 | /** @gqlField */ 15 | name: string; 16 | } 17 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/InterfaceTypeImplementsInterface.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default interface User extends HasName { 3 | __typename: "User"; 4 | /** @gqlField */ 5 | hello: string; 6 | 7 | /** @gqlField */ 8 | name: string; 9 | } 10 | 11 | /** @gqlInterface */ 12 | interface HasName { 13 | /** @gqlField */ 14 | name: string; 15 | } 16 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/InterfaceWithDescription.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The root of all evil. 3 | * 4 | * @gqlType 5 | */ 6 | export default interface SomeType { 7 | /** @gqlField */ 8 | hello: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/InterfaceWithDescriptionAndCustomName.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The root of all evil. 3 | * 4 | * @gqlType SomeType 5 | */ 6 | export default interface NotQuery { 7 | /** @gqlField */ 8 | hello: string; 9 | } 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/QueryFromInterface.invlaid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default interface Query { 3 | /** @gqlField */ 4 | hello: string; 5 | } 6 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/RenamedType.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlType SomeType 3 | */ 4 | interface MyInterface { 5 | /** @gqlField */ 6 | hello: string; 7 | } 8 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/TagAttachedToWrongNode.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | function MyFunc() {} 3 | -------------------------------------------------------------------------------- /src/tests/fixtures/type_definitions_from_interface/TagAttachedToWrongNode.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlType */ 5 | function MyFunc() {} 6 | 7 | ----------------- 8 | OUTPUT 9 | ----------------- 10 | src/tests/fixtures/type_definitions_from_interface/TagAttachedToWrongNode.ts:1:5 - error: `@gqlType` can only be used on class, interface or type declarations. e.g. `class MyType {}` 11 | 12 | 1 /** @gqlType */ 13 | ~~~~~~~~~ 14 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/ImplementorMissingTypename.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User implements IPerson { 3 | /** @gqlField */ 4 | name: string = "Alice"; 5 | } 6 | 7 | /** @gqlInterface */ 8 | export interface IPerson { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/MethodTypename.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | __typename() { 4 | return "User"; 5 | } 6 | /** @gqlField */ 7 | name: string = "Alice"; 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertySignatureTypename.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User implements IPerson { 3 | __typename: "User"; 4 | /** @gqlField */ 5 | name: string; 6 | } 7 | 8 | /** @gqlInterface */ 9 | export interface IPerson { 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertySignatureTypenameIncorrectName.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User implements IPerson { 3 | __typename: "Group"; 4 | /** @gqlField */ 5 | name: string; 6 | } 7 | 8 | /** @gqlInterface */ 9 | export interface IPerson { 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertySignatureTypenameMissingType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User implements IPerson { 3 | __typename; 4 | /** @gqlField */ 5 | name: string; 6 | } 7 | 8 | /** @gqlInterface */ 9 | export interface IPerson { 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertySignatureTypenameNonLiteralType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User implements IPerson { 3 | __typename: string; 4 | /** @gqlField */ 5 | name: string; 6 | } 7 | 8 | /** @gqlInterface */ 9 | export interface IPerson { 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertyTypename.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | __typename = "User" as const; 4 | /** @gqlField */ 5 | name: string = "Alice"; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertyTypenameDoesNotMatchClassName.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | __typename = "Group" as const; 4 | /** @gqlField */ 5 | name: string = "Alice"; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertyTypenameDoesNotMatchDeclaredName.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType User */ 2 | export class UserModel { 3 | __typename = "UserModel" as const; 4 | /** @gqlField */ 5 | name: string = "Alice"; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertyTypenameMustNeedToBeDeclaredAsConst.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | __typename = "User"; 4 | /** @gqlField */ 5 | name: string = "Alice"; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertyTypenameMustNeedToBeDeclaredAsExactlyConst.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | __typename = "User" as Foo; 4 | /** @gqlField */ 5 | name: string = "Alice"; 6 | } 7 | 8 | type Foo = string; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertyTypenameNoInitializer.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | __typename: string; 4 | /** @gqlField */ 5 | name: string = "Alice"; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/PropertyTypenameNonStringInitializer.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | __typename = 1 as const; 4 | /** @gqlField */ 5 | name: string = "Alice"; 6 | } 7 | -------------------------------------------------------------------------------- /src/tests/fixtures/typename/UnionMemberMissingTypename.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | /** @gqlField */ 4 | name: string = "Alice"; 5 | } 6 | 7 | /** @gqlType */ 8 | class Group { 9 | /** @gqlField */ 10 | name: string = "Alice Fan Club"; 11 | } 12 | 13 | /** @gqlUnion */ 14 | export type MyUnion = User | Group; 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/DefineUnionOfOneType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | __typename = "User" as const; 4 | /** @gqlField */ 5 | name: string; 6 | } 7 | 8 | /** @gqlUnion */ 9 | type Actor = User; 10 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/DefineUnionType.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | class User { 9 | __typename = "User" as const; 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | 14 | /** @gqlType */ 15 | class Entity { 16 | __typename = "Entity" as const; 17 | /** @gqlField */ 18 | description: string; 19 | } 20 | 21 | /** @gqlUnion */ 22 | type Actor = User | Entity; 23 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/DefineUnionTypeContainingInterface.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | class User { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | 13 | /** @gqlInterface */ 14 | interface Entity { 15 | /** @gqlField */ 16 | description: string; 17 | } 18 | 19 | /** @gqlUnion */ 20 | type Actor = User | Entity; 21 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/DefineUnionTypeReferencingInputType.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | class User { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | 13 | /** @gqlInput */ 14 | type Entity = { 15 | description: string; 16 | }; 17 | 18 | /** @gqlUnion */ 19 | type Actor = User | Entity; 20 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/DefineUnionTypeReferencingLiteral.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | class User { 9 | /** @gqlField */ 10 | name: string; 11 | } 12 | 13 | /** @gqlUnion */ 14 | type Actor = User | "LOL"; 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/DefineUnionTypeWithInterfaces.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | interface User { 9 | __typename: "User"; 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | 14 | /** @gqlType */ 15 | interface Entity { 16 | __typename: "Entity"; 17 | /** @gqlField */ 18 | description: string; 19 | } 20 | 21 | /** @gqlUnion */ 22 | type Actor = User | Entity; 23 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/DefineUnionTypeWithTypeLiterals.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | type User = { 9 | __typename: "User"; 10 | /** @gqlField */ 11 | name: string; 12 | }; 13 | 14 | /** @gqlType */ 15 | type Entity = { 16 | __typename: "Entity"; 17 | /** @gqlField */ 18 | description: string; 19 | }; 20 | 21 | /** @gqlUnion */ 22 | type Actor = User | Entity; 23 | -------------------------------------------------------------------------------- /src/tests/fixtures/unions/UnionAsMemberOfItself.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export default class SomeType { 3 | /** @gqlField */ 4 | me: Actor; 5 | } 6 | 7 | /** @gqlType */ 8 | class User { 9 | __typename = "User"; 10 | /** @gqlField */ 11 | name: string; 12 | } 13 | 14 | /** @gqlType */ 15 | class Entity { 16 | __typename = "Entity"; 17 | /** @gqlField */ 18 | description: string; 19 | } 20 | 21 | /** @gqlUnion */ 22 | type Actor = User | Entity | Actor; 23 | -------------------------------------------------------------------------------- /src/tests/fixtures/user_error/GqlTagDoesNotExist.ts: -------------------------------------------------------------------------------- 1 | /** @gqlFiled */ 2 | -------------------------------------------------------------------------------- /src/tests/fixtures/user_error/GqlTagDoesNotExist.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlFiled */ 5 | 6 | ----------------- 7 | OUTPUT 8 | ----------------- 9 | src/tests/fixtures/user_error/GqlTagDoesNotExist.ts:1:6 - error: `@gqlFiled` is not a valid Grats tag. Valid tags are: `@gqlType`, `@gqlField`, `@gqlScalar`, `@gqlInterface`, `@gqlEnum`, `@gqlUnion`, `@gqlInput`, `@gqlDirective`, `@gqlAnnotate`. 10 | 11 | 1 /** @gqlFiled */ 12 | ~~~~~~~~ 13 | -------------------------------------------------------------------------------- /src/tests/fixtures/user_error/InvalidSyntax.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class #Foo { 3 | 4 | } -------------------------------------------------------------------------------- /src/tests/fixtures/user_error/InvalidSyntax.invalid.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlType */ 5 | class #Foo { 6 | 7 | } 8 | ----------------- 9 | OUTPUT 10 | ----------------- 11 | src/tests/fixtures/user_error/InvalidSyntax.invalid.ts:2:7 - error TS1005: '{' expected. 12 | 13 | 2 class #Foo { 14 | ~~~~ 15 | -------------------------------------------------------------------------------- /src/tests/fixtures/user_error/KillsParentOnExceptionOnNonField.invalid.ts: -------------------------------------------------------------------------------- 1 | /** @killsParentOnException */ 2 | const foo = "bar"; 3 | 4 | /** @gqlType */ 5 | type Foo = { 6 | /** @gqlField */ 7 | bar: string; 8 | }; 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/user_error/TypeErrorWithTypeCheckingEnabled.ts: -------------------------------------------------------------------------------- 1 | // { "reportTypeScriptTypeErrors": true, "tsVersion": "5.0.2" } 2 | /** @gqlType */ 3 | class Foo { 4 | /** @gqlField */ 5 | someField(): string { 6 | return 10; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/tests/fixtures/user_error/WrongCaseGqlTag.ts: -------------------------------------------------------------------------------- 1 | /** @GQLField */ 2 | function field() {} 3 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/complexDefaultInput/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | type SomeObj = { 5 | a: string; 6 | }; 7 | 8 | /** 9 | * @gqlQueryField 10 | */ 11 | export function hello({ 12 | someObj = { a: "Sup" }, 13 | }: { 14 | someObj: SomeObj; 15 | }): string { 16 | return someObj.a; 17 | } 18 | 19 | export const query = ` 20 | query { 21 | hello 22 | } 23 | `; 24 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/deprecated/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlQueryField 3 | * @deprecated For reasons 4 | */ 5 | export function hello(): string { 6 | return "Hello World"; 7 | } 8 | 9 | /** 10 | * @gqlQueryField 11 | * @deprecated 12 | */ 13 | export function goodBye(): string { 14 | return "Farewell World"; 15 | } 16 | 17 | export const query = ` 18 | query { 19 | hello 20 | } 21 | `; 22 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/derivedContext/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlContext */ 2 | type Ctx = {}; 3 | 4 | type SomeCtx = { name: string }; 5 | 6 | /** @gqlContext */ 7 | export function derived(): SomeCtx { 8 | return { name: "Roger" }; 9 | } 10 | 11 | /** @gqlQueryField */ 12 | export function hello(someCtx: SomeCtx): string { 13 | return `Hello ${someCtx.name}`; 14 | } 15 | 16 | export const query = ` 17 | query { 18 | hello 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/enumDefault/index.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/172#issuecomment-2685496600 2 | 3 | /** @gqlEnum */ 4 | type GreetingOptions = "Hello" | "Greetings" | "Sup"; 5 | 6 | /** @gqlQueryField */ 7 | export function hello(greeting: GreetingOptions | null = "Greetings"): string { 8 | return `${greeting} World`; 9 | } 10 | 11 | export const query = /* GraphQL */ ` 12 | query { 13 | hello 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/functionField/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function hello(): string { 3 | return "Hello World"; 4 | } 5 | 6 | export const query = ` 7 | query { 8 | hello 9 | } 10 | `; 11 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/functionField/index.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlQueryField */ 5 | export function hello(): string { 6 | return "Hello World"; 7 | } 8 | 9 | export const query = ` 10 | query { 11 | hello 12 | } 13 | `; 14 | 15 | ----------------- 16 | OUTPUT 17 | ----------------- 18 | { 19 | "data": { 20 | "hello": "Hello World" 21 | } 22 | } -------------------------------------------------------------------------------- /src/tests/integrationFixtures/functionFieldRenamed/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField hello */ 2 | export function notHello(): string { 3 | return "Hello World"; 4 | } 5 | 6 | export const query = ` 7 | query { 8 | hello 9 | } 10 | `; 11 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/functionFieldRenamed/index.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlQueryField hello */ 5 | export function notHello(): string { 6 | return "Hello World"; 7 | } 8 | 9 | export const query = ` 10 | query { 11 | hello 12 | } 13 | `; 14 | 15 | ----------------- 16 | OUTPUT 17 | ----------------- 18 | { 19 | "data": { 20 | "hello": "Hello World" 21 | } 22 | } -------------------------------------------------------------------------------- /src/tests/integrationFixtures/getAcessor/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function me(): User { 3 | return new User(); 4 | } 5 | 6 | /** @gqlType */ 7 | class User { 8 | /** @gqlField */ 9 | get hello(): string { 10 | return "Hello world!"; 11 | } 12 | } 13 | 14 | export const query = ` 15 | query { 16 | me { 17 | hello 18 | } 19 | }`; 20 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/killsParentOnExceptionOnQuery/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlQueryField 3 | * @killsParentOnException 4 | */ 5 | export function alwaysThrowsKillsParentOnException(): string { 6 | throw new Error("This error should kill Query"); 7 | } 8 | 9 | /** @gqlQueryField */ 10 | export function hello(): string { 11 | return "Hello World"; 12 | } 13 | 14 | export const query = ` 15 | query { 16 | alwaysThrowsKillsParentOnException 17 | hello 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/nonNullArgWithDefault/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function hello({ greeting = "Hello" }: { greeting: string }): string { 3 | return `${greeting}, world!`; 4 | } 5 | 6 | export const query = ` 7 | query { 8 | hello 9 | } 10 | `; 11 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/nonNullArgWithDefault/index.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlQueryField */ 5 | export function hello({ greeting = "Hello" }: { greeting: string }): string { 6 | return `${greeting}, world!`; 7 | } 8 | 9 | export const query = ` 10 | query { 11 | hello 12 | } 13 | `; 14 | 15 | ----------------- 16 | OUTPUT 17 | ----------------- 18 | { 19 | "data": { 20 | "hello": "Hello, world!" 21 | } 22 | } -------------------------------------------------------------------------------- /src/tests/integrationFixtures/nonNullEnumDefault/index.ts: -------------------------------------------------------------------------------- 1 | // https://github.com/captbaritone/grats/issues/174 2 | 3 | /** @gqlEnum */ 4 | type GreetingOptions = "Hello" | "Greetings" | "Sup"; 5 | 6 | /** @gqlQueryField */ 7 | export function hello(greeting: GreetingOptions = "Greetings"): string { 8 | return `${greeting} World`; 9 | } 10 | 11 | export const query = /* GraphQL */ ` 12 | query { 13 | hello 14 | } 15 | `; 16 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/nonNullableListIncludesNull/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function someList(): string[] { 3 | // @ts-ignore 4 | return ["a", null, "b"]; 5 | } 6 | 7 | /** @gqlQueryField */ 8 | export function someListOfLists(): string[][] { 9 | // @ts-ignore 10 | return [["a"], ["b", null, "c"]]; 11 | } 12 | 13 | export const query = ` 14 | query { 15 | someList 16 | someListOfLists 17 | } 18 | `; 19 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/parameterPropertyRenamed/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function me(): User { 3 | return new User(); 4 | } 5 | 6 | /** @gqlType */ 7 | class User { 8 | constructor( 9 | /** @gqlField hello */ 10 | public NOT_THIS: string = "world", 11 | ) {} 12 | } 13 | 14 | export const query = ` 15 | query { 16 | me { 17 | hello 18 | } 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/positionalNonNullArgWithDefault/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function hello(greeting: string = "Hello"): string { 3 | return `${greeting}, world!`; 4 | } 5 | 6 | export const query = ` 7 | query { 8 | hello 9 | } 10 | `; 11 | -------------------------------------------------------------------------------- /src/tests/integrationFixtures/positionalNonNullArgWithDefault/index.ts.expected: -------------------------------------------------------------------------------- 1 | ----------------- 2 | INPUT 3 | ----------------- 4 | /** @gqlQueryField */ 5 | export function hello(greeting: string = "Hello"): string { 6 | return `${greeting}, world!`; 7 | } 8 | 9 | export const query = ` 10 | query { 11 | hello 12 | } 13 | `; 14 | 15 | ----------------- 16 | OUTPUT 17 | ----------------- 18 | { 19 | "data": { 20 | "hello": "Hello, world!" 21 | } 22 | } -------------------------------------------------------------------------------- /src/tests/integrationFixtures/resolverErrorElidedToNull/index.ts: -------------------------------------------------------------------------------- 1 | /** @gqlQueryField */ 2 | export function alwaysThrows(): string { 3 | throw new Error("This should null out the field"); 4 | } 5 | 6 | export const query = ` 7 | query { 8 | alwaysThrows 9 | } 10 | `; 11 | -------------------------------------------------------------------------------- /website/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | /node_modules 3 | 4 | # Production 5 | /build 6 | 7 | # Generated files 8 | .docusaurus 9 | .cache-loader 10 | 11 | # Misc 12 | .DS_Store 13 | .env.local 14 | .env.development.local 15 | .env.test.local 16 | .env.production.local 17 | 18 | npm-debug.log* 19 | yarn-debug.log* 20 | yarn-error.log* 21 | -------------------------------------------------------------------------------- /website/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve("@docusaurus/core/lib/babel/preset")], 3 | }; 4 | -------------------------------------------------------------------------------- /website/docs/01-getting-started/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "collapsible": true, 3 | "collapsed": false 4 | } 5 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "collapsible": true, 3 | "collapsed": true 4 | } 5 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/02-resolver-signature-function.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | type User = { 3 | _bestFriendID: number; 4 | }; 5 | 6 | /** @gqlField */ 7 | export function friends(user: User, order: string, context: GqlContext): User { 8 | return context.db.getSortedFriends(user._bestFriendID, order); 9 | } 10 | 11 | /** @gqlContext */ 12 | type GqlContext = { 13 | db: { getSortedFriends(id: number, order: string): User }; 14 | }; 15 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/02-resolver-signature-method.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | _bestFriendID: number; 4 | /** @gqlField */ 5 | bestFriend(order: string, context: GqlContext): User { 6 | return context.db.getSortedFriends(this._bestFriendID, order); 7 | } 8 | } 9 | 10 | /** @gqlContext */ 11 | type GqlContext = { 12 | db: { getSortedFriends(id: number, order: string): User }; 13 | }; 14 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/03-description-enum-fail.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlEnum */ 2 | type GreetingStyle = 3 | // highlight-start 4 | /** For a business greeting */ 5 | // highlight-end 6 | | "formal" 7 | // highlight-start 8 | /** For a friendly greeting */ 9 | // highlight-end 10 | | "casual"; 11 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/03-description-example.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A registered user of the system. 3 | * @gqlType 4 | */ 5 | class User { 6 | /** 7 | * A friendly greeting for the user, intended for 8 | * their first visit. 9 | * @gqlField 10 | */ 11 | hello( 12 | /** The salutation to use */ 13 | greeting: string, 14 | ): string { 15 | return `${greeting} World`; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/04-renaming-field.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | name: string; 4 | 5 | // highlight-start 6 | /** @gqlField greeting */ 7 | // highlight-end 8 | getGreeting(): string { 9 | return `Hello, ${this.name}`; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/04-renaming-type.grats.ts: -------------------------------------------------------------------------------- 1 | // highlight-start 2 | /** @gqlType User */ 3 | // highlight-end 4 | export class UserModel { 5 | /** @gqlField */ 6 | name: string; 7 | } 8 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/05-deprecated-example.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | /** 4 | * @gqlField 5 | * @deprecated Please use myNewField instead. 6 | */ 7 | oldField: string; 8 | 9 | /** @gqlField */ 10 | newField: string; 11 | } 12 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/06-nullability.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class MyType { 3 | /** 4 | * @gqlField 5 | * @killsParentOnException 6 | */ 7 | myField(): string { 8 | if (Math.random() > 0.5) { 9 | throw new Error("Bang"); 10 | } 11 | return "Whew!"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/03-resolvers/snippets/deprecated-workaround.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | // Not deprecated! 4 | name: string; 5 | 6 | /** 7 | * @gqlField name 8 | * @deprecated Not supported externally any more 9 | */ 10 | graphQLName(): string { 11 | return this.name; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "collapsed": true, 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/01-root-type-with-description.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * # Welcome to GenericCorp's GraphQL Schema! 3 | * 4 | * This is root type of our system. Everything you need can be access from here. 5 | * @gqlType 6 | */ 7 | type Query = unknown; 8 | 9 | /** @gqlQueryField */ 10 | export function greet(): string { 11 | return "Hello world"; 12 | } 13 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/01-types-alias.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export type MyType = { 3 | /** @gqlField */ 4 | someField: string; 5 | }; 6 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/01-types-class.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class MyClass { 3 | /** @gqlField */ 4 | someField: string; 5 | } 6 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/01-types-implement-interface.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface Person { 3 | /** @gqlField */ 4 | name: string; 5 | } 6 | 7 | /** @gqlType */ 8 | // highlight-start 9 | export class User implements Person { 10 | // highlight-end 11 | /** @gqlField */ 12 | name: string; 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/01-types-interface-implement-interface.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface Person { 3 | /** @gqlField */ 4 | name: string; 5 | } 6 | 7 | /** @gqlType */ 8 | // highlight-start 9 | export interface User extends Person { 10 | // highlight-end 11 | __typename: "User"; 12 | /** @gqlField */ 13 | name: string; 14 | } 15 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/01-types-interface.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export interface MyType { 3 | /** @gqlField */ 4 | someField: string; 5 | } 6 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/01-types-renaming.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType User */ 2 | class UserModel { 3 | /** @gqlField */ 4 | someField: string; 5 | } 6 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/02-function-extending-mutation.grats.ts: -------------------------------------------------------------------------------- 1 | // trim-start 2 | const DB: any = {}; 3 | 4 | /** @gqlType */ 5 | type User = { 6 | /** @gqlField */ 7 | name: string; 8 | }; 9 | 10 | // trim-end 11 | /** @gqlMutationField */ 12 | export function deleteUser(id: string): boolean { 13 | return DB.deleteUser(id); 14 | } 15 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/02-function-extending-query.grats.ts: -------------------------------------------------------------------------------- 1 | // trim-start 2 | const DB: any = {}; 3 | 4 | /** @gqlType */ 5 | type User = { 6 | /** @gqlField */ 7 | name: string; 8 | }; 9 | 10 | // trim-end 11 | /** @gqlQueryField */ 12 | export function userById(id: string): User { 13 | return DB.getUserById(id); 14 | } 15 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/02-parameter-property-fields.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | constructor( 4 | /** @gqlField */ 5 | public name: string, 6 | ) {} 7 | } 8 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/02-property-and-method.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | class User { 3 | /** 4 | * A description of some field. 5 | * @gqlField 6 | */ 7 | someField: string; 8 | 9 | /** @gqlField */ 10 | myField(): string { 11 | return "Hello World"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/02-static-method-extending-query.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlType */ 2 | export class User { 3 | constructor( 4 | /** @gqlField */ 5 | public name: string, 6 | ) {} 7 | 8 | // highlight-start 9 | /** @gqlQueryField */ 10 | static me(): User { 11 | return new User("Elizabeth"); 12 | } 13 | // highlight-end 14 | } 15 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/04-interface-declaration.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A description of my interface. 3 | * @gqlInterface MyInterfaceName 4 | */ 5 | interface MyClass { 6 | /** @gqlField */ 7 | someField: string; 8 | } 9 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/04-interface-implement-interface.grats.ts: -------------------------------------------------------------------------------- 1 | /** @gqlInterface */ 2 | interface Person { 3 | /** @gqlField */ 4 | name: string; 5 | } 6 | 7 | /** @gqlInterface */ 8 | // highlight-start 9 | interface User extends Person { 10 | // highlight-end 11 | /** @gqlField */ 12 | name: string; 13 | 14 | /** @gqlField */ 15 | username: string; 16 | } 17 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/04-merged-interface-renaming.grats.ts: -------------------------------------------------------------------------------- 1 | import { ID } from "grats"; 2 | 3 | /** @gqlType Node */ 4 | interface GqlNode { 5 | /** @gqlField */ 6 | id: ID; 7 | } 8 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/08-specified-by.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlScalar 3 | * @gqlAnnotate specifiedBy(url: "https://tools.ietf.org/html/rfc4122") 4 | */ 5 | type UUID = string; 6 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/10-one-of-input-descriptions.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type UserBy = 5 | | { 6 | /** Fetch the user by email */ 7 | email: string; 8 | } 9 | | { 10 | /** Fetch the user by username */ 11 | username: string; 12 | }; 13 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/10-one-of-input.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlInput 3 | */ 4 | export type UserBy = { email: string } | { username: string }; 5 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/11-directive-args-defaults.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlDirective on FIELD_DEFINITION 3 | */ 4 | function myDirective({ greeting = "Hello" }: { greeting: string }) {} 5 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/11-directive-args-deprecated.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @gqlDirective on FIELD_DEFINITION 3 | */ 4 | function myDirective(args: { 5 | /** @deprecated Unused! */ 6 | someArg?: string | null; 7 | }) { 8 | // ... 9 | } 10 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/11-directive-args.grats.ts: -------------------------------------------------------------------------------- 1 | // trim-start 2 | type SomeType = any; 3 | // trim-end 4 | /** 5 | * @gqlDirective on FIELD_DEFINITION 6 | */ 7 | function myDirective(args: { someArg: string }, someNonGqlArg: SomeType) {} 8 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/11-directive-def.grats.ts: -------------------------------------------------------------------------------- 1 | // trim-start 2 | import { Int } from "grats"; 3 | // trim-end 4 | /** 5 | * @gqlDirective on FIELD_DEFINITION 6 | */ 7 | function cost(args: { credits: Int }) { 8 | // ... 9 | } 10 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/11-directive-locations.grats.ts: -------------------------------------------------------------------------------- 1 | // trim-start 2 | import { Int } from "grats"; 3 | // trim-end 4 | /** 5 | * @gqlDirective cost repeatable on FIELD_DEFINITION | OBJECT 6 | */ 7 | function applyCost(args: { credits: Int }) { 8 | // ... 9 | } 10 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/12-directive-annotations-1.grats.ts: -------------------------------------------------------------------------------- 1 | // trim-start 2 | /** @gqlDirective on FIELD_DEFINITION */ 3 | function myDirective() { 4 | // ... 5 | } 6 | // trim-end 7 | /** 8 | * @gqlQueryField 9 | * @gqlAnnotate myDirective 10 | */ 11 | export function greet(): string { 12 | return "Hello"; 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/04-docblock-tags/snippets/12-directive-annotations-2.grats.ts: -------------------------------------------------------------------------------- 1 | // trim-start 2 | /** @gqlDirective on FIELD_DEFINITION */ 3 | function myDirective(args: { someArg: string }) { 4 | // ... 5 | } 6 | // trim-end 7 | /** 8 | * @gqlQueryField 9 | * @gqlAnnotate myDirective(someArg: "Some String") 10 | */ 11 | export function greet(): string { 12 | return "Hello"; 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/05-examples/01-apollo-server.md: -------------------------------------------------------------------------------- 1 | # Apollo Server 2 | 3 | A very minimal example of using Grats with Apollo Server 4 | 5 | **https://github.com/captbaritone/grats/tree/main/examples/apollo-server/** 6 | 7 | ## Libraries used 8 | 9 | - `@apollo/server` 10 | - `graphql-js` 11 | -------------------------------------------------------------------------------- /website/docs/05-examples/02-express-graphql.md: -------------------------------------------------------------------------------- 1 | # Express GraphQL 2 | 3 | A very minimal example of using Grats with `express-graphql`. 4 | 5 | **https://github.com/captbaritone/grats/tree/main/examples/express-graphql** 6 | 7 | :::caution 8 | `express-graphql` is deprecated in favor of `graphql-http`. See [GraphQL HTTP with Express](./03-graphql-http.md) for an example using `graphql-http`. 9 | ::: 10 | 11 | ## Libraries used 12 | 13 | - `express` 14 | - `express-graphql` 15 | - `graphql-js` 16 | -------------------------------------------------------------------------------- /website/docs/05-examples/03-graphql-http.md: -------------------------------------------------------------------------------- 1 | # GraphQL HTTP with Express 2 | 3 | A very minimal example of using Grats with `graphql-http` and `express`. 4 | 5 | **https://github.com/captbaritone/grats/tree/main/examples/express-graphql-http** 6 | 7 | ## Libraries used 8 | 9 | - `express` 10 | - `graphql-http` 11 | - `graphql-js` 12 | -------------------------------------------------------------------------------- /website/docs/05-examples/04-yoga.md: -------------------------------------------------------------------------------- 1 | # Yoga 2 | 3 | A very minimal example of using Grats with `yoga-graphql` and Node's built in HTTP server. This example also includes an working example of GraphQL subscriptions. 4 | 5 | **https://github.com/captbaritone/grats/tree/main/examples/yoga** 6 | 7 | ## Libraries used 8 | 9 | - `yoga-graphql` 10 | -------------------------------------------------------------------------------- /website/docs/05-examples/08-next-js.md: -------------------------------------------------------------------------------- 1 | # Next.js 2 | 3 | A minimal example showing using Grats with Next.js. 4 | 5 | **https://github.com/captbaritone/grats/tree/main/examples/next-js** 6 | 7 | ## Libraries used 8 | 9 | - `yoga-graphql` 10 | - `next` 11 | -------------------------------------------------------------------------------- /website/docs/05-examples/09-strict-semantic-nullability.md: -------------------------------------------------------------------------------- 1 | # Strict Semantic Nullability 2 | 3 | This example demonstrates Grats' experimental support for [Strict Semantic Nullability](../05-guides/04-strict-semantic-nullability.mdx). 4 | 5 | **https://github.com/captbaritone/grats/tree/main/examples/strict-semantic-nullability** 6 | 7 | ## Libraries used 8 | 9 | - `yoga-graphql` 10 | - `next` 11 | -------------------------------------------------------------------------------- /website/docs/05-examples/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "collapsed": true, 3 | "collapsible": true 4 | } 5 | -------------------------------------------------------------------------------- /website/docs/05-guides/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "Guides", 3 | "collapsed": true, 4 | "collapsible": true, 5 | "link": {} 6 | } 7 | -------------------------------------------------------------------------------- /website/docs/05-guides/snippets/subscription-example.grats.ts: -------------------------------------------------------------------------------- 1 | import { Int } from "grats"; 2 | 3 | /** @gqlSubscriptionField */ 4 | export async function* countdown(): AsyncIterable { 5 | for (let i = 10; i >= 0; i--) { 6 | await sleep(1); 7 | yield i; 8 | } 9 | } 10 | 11 | function sleep(s: number) { 12 | return new Promise((resolve) => setTimeout(resolve, s * 1000)); 13 | } 14 | -------------------------------------------------------------------------------- /website/docs/06-faq/_category_.json: -------------------------------------------------------------------------------- 1 | { 2 | "label": "FAQ", 3 | "collapsed": true, 4 | "collapsible": true, 5 | "link": {} 6 | } 7 | -------------------------------------------------------------------------------- /website/plugins/webpack.js: -------------------------------------------------------------------------------- 1 | module.exports = function (_context, _options) { 2 | return { 3 | name: "custom-docusaurus-plugin", 4 | configureWebpack(_config, _isServer, _utils) { 5 | return { 6 | resolve: { 7 | fallback: { 8 | path: require.resolve("path-browserify"), 9 | }, 10 | }, 11 | node: { 12 | __dirname: "mock", 13 | }, 14 | }; 15 | }, 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /website/src/components/HomepageFeatures/snippets/homepageExample.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A user in our kick-ass system! 3 | * @gqlType */ 4 | class User { 5 | /** @gqlField */ 6 | name: string; 7 | 8 | /** @gqlField */ 9 | greet(greeting: string): string { 10 | return `${greeting}, ${this.name}`; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /website/src/components/HomepageFeatures/snippets/homepageExampleFP.grats.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * A user in our kick-ass system! 3 | * @gqlType */ 4 | type User = { 5 | /** @gqlField */ 6 | name: string; 7 | }; 8 | 9 | /** @gqlField */ 10 | export function greet(user: User, greeting: string): string { 11 | return `${greeting}, ${user.name}`; 12 | } 13 | -------------------------------------------------------------------------------- /website/src/components/HomepageFeatures/styles.module.css: -------------------------------------------------------------------------------- 1 | .features { 2 | display: flex; 3 | align-items: center; 4 | padding: 2rem 0; 5 | width: 100%; 6 | } 7 | 8 | .featureSvg { 9 | height: 200px; 10 | width: 200px; 11 | } 12 | -------------------------------------------------------------------------------- /website/src/components/PlaygroundFeatures/editors/theme.ts: -------------------------------------------------------------------------------- 1 | import { EditorView } from "@codemirror/view"; 2 | 3 | export const Theme = EditorView.theme({ 4 | "&": { fontSize: "18px" }, 5 | ".cm-gutters": { 6 | backgroundColor: "var(--ifm-color-emphasis-100)", 7 | color: "var(--ifm-font-color-base)", 8 | border: "none", 9 | borderRight: "1px solid var(--ifm-color-emphasis-300)", 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /website/src/components/PlaygroundFeatures/index.module.css: -------------------------------------------------------------------------------- 1 | html, 2 | body, 3 | .wrapper { 4 | height: 100%; 5 | } 6 | body { 7 | font-family: sans-serif; 8 | padding: 0; 9 | margin: 0; 10 | } 11 | 12 | .cm-editor { 13 | height: 100%; 14 | width: 100%; 15 | } 16 | .cm-scroller { 17 | overflow: auto; 18 | } 19 | 20 | #format-button { 21 | background-color: #eee; 22 | border: 1px solid #ccc; 23 | border-radius: 4px; 24 | cursor: pointer; 25 | } 26 | -------------------------------------------------------------------------------- /website/static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/captbaritone/grats/90c6939c6badd45db76df03dc817a7f3fc3d505b/website/static/.nojekyll -------------------------------------------------------------------------------- /website/static/img/docusaurus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/captbaritone/grats/90c6939c6badd45db76df03dc817a7f3fc3d505b/website/static/img/docusaurus.png -------------------------------------------------------------------------------- /website/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/captbaritone/grats/90c6939c6badd45db76df03dc817a7f3fc3d505b/website/static/img/favicon.ico -------------------------------------------------------------------------------- /website/static/img/grats-og.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/captbaritone/grats/90c6939c6badd45db76df03dc817a7f3fc3d505b/website/static/img/grats-og.png --------------------------------------------------------------------------------