Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/apollo-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"grats": {
"nullableByDefault": false,
"importModuleSpecifierEnding": ".js"
"nullableByDefault": false
},
"compilerOptions": {
"outDir": "dist",
Expand Down
3 changes: 1 addition & 2 deletions examples/express-graphql-http/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"grats": {
"nullableByDefault": false,
"importModuleSpecifierEnding": ".js"
"nullableByDefault": false
},
"compilerOptions": {
"outDir": "dist",
Expand Down
3 changes: 1 addition & 2 deletions examples/incremental-migration/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"tsSchema": "./schemas/gratsGeneratedSchema.ts",
"graphqlSchema": "gratsSchema.graphql",
"tsSchemaHeader": "// DO NOT USE DIRECTLY. Prefer the merged schema in `./mergedSchema.ts`.",
"schemaHeader": "# DO NOT USE DIRECTLY. Prefer the merged schema in `../schema.graphql`.",
"importModuleSpecifierEnding": ".js"
"schemaHeader": "# DO NOT USE DIRECTLY. Prefer the merged schema in `../schema.graphql`."
},
"compilerOptions": {
"outDir": "dist",
Expand Down
4 changes: 1 addition & 3 deletions examples/production-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"grats": {
"importModuleSpecifierEnding": ".js"
},
"grats": {},
"compilerOptions": {
"outDir": "dist",
"module": "NodeNext",
Expand Down
3 changes: 1 addition & 2 deletions examples/strict-semantic-nullability/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"grats": {
"nullableByDefault": true,
"strictSemanticNullability": true,
"importModuleSpecifierEnding": ".js"
"strictSemanticNullability": true
},
"compilerOptions": {
"outDir": "dist",
Expand Down
3 changes: 1 addition & 2 deletions examples/yoga/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"grats": {
"nullableByDefault": false,
"importModuleSpecifierEnding": ".js"
"nullableByDefault": false
},
"compilerOptions": {
"outDir": "dist",
Expand Down
6 changes: 2 additions & 4 deletions llm-docs/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,9 @@ Default:

### "importModuleSpecifierEnding": string

This option allows you configure an extension that will be appended to the end of all import paths in the generated TypeScript schema file.
The extension appended to the end of all import paths in the generated TypeScript schema file. Defaults to `.js` which works for both CommonJS and ES module projects. Set to an empty string to omit the extension.

When building a package that uses ES modules, import paths must not omit the file extension. In TypeScript code this generally means import paths must end with `.js`. If set to null, no ending will be appended.

Default: `""`
Default: `".js"`

* * *

Expand Down
8 changes: 3 additions & 5 deletions scripts/TGratsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ export type GratsConfig = {
*/
tsClientEnumsHeader: string | null;
/**
* This option allows you configure an extension that will be appended to
* the end of all import paths in the generated TypeScript schema file.
* When building a package that uses ES modules, import paths must not
* omit the file extension. In TypeScript code this generally means import
* paths must end with `.js`. If set to null, no ending will be appended.
* The extension appended to the end of all import paths in the generated
* TypeScript schema file. Defaults to `.js` which works for both CommonJS
* and ES module projects. Set to an empty string to omit the extension.
*/
importModuleSpecifierEnding: string;
/**
Expand Down
4 changes: 2 additions & 2 deletions src/configSpecRaw.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
"default": "/**\n * TypeScript enum definitions generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */"
},
"importModuleSpecifierEnding": {
"description": "This option allows you configure an extension that will be appended to the end of all import paths in the generated TypeScript schema file.\nWhen building a package that uses ES modules, import paths must not omit the file extension. In TypeScript code this generally means import paths must end with `.js`. If set to null, no ending will be appended.",
"description": "The extension appended to the end of all import paths in the generated TypeScript schema file. Defaults to `.js` which works for both CommonJS and ES module projects. Set to an empty string to omit the extension.",
"type": { "kind": "string" },
"nullable": false,
"default": ""
"default": ".js"
},
"EXPERIMENTAL__emitMetadata": {
"description": "EXPERIMENTAL: THIS OPTION WILL BE RENAMED OR REMOVED IN A FUTURE RELEASE\nEmit a JSON file alongside the generated schema file which contains the metadata containing information about the resolvers.",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/configParserFixtures/empty.json.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"schemaHeader": "# Schema generated by Grats (https://grats.capt.dev)\n# Do not manually edit. Regenerate by running `npx grats`.",
"tsSchemaHeader": "/**\n * Executable schema generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */",
"tsClientEnumsHeader": "/**\n * TypeScript enum definitions generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */",
"importModuleSpecifierEnding": "",
"importModuleSpecifierEnding": ".js",
"EXPERIMENTAL__emitMetadata": false,
"EXPERIMENTAL__emitResolverMap": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"schemaHeader": "# Schema generated by Grats (https://grats.capt.dev)\n# Do not manually edit. Regenerate by running `npx grats`.",
"tsSchemaHeader": "/**\n * Executable schema generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */",
"tsClientEnumsHeader": "/**\n * TypeScript enum definitions generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */",
"importModuleSpecifierEnding": "",
"importModuleSpecifierEnding": ".js",
"EXPERIMENTAL__emitMetadata": true,
"EXPERIMENTAL__emitResolverMap": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"schemaHeader": "/**\n * An amazing GraphQL schema\n */",
"tsSchemaHeader": "/**\n * Executable schema generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */",
"tsClientEnumsHeader": "/**\n * TypeScript enum definitions generated by Grats (https://grats.capt.dev)\n * Do not manually edit. Regenerate by running `npx grats`.\n */",
"importModuleSpecifierEnding": "",
"importModuleSpecifierEnding": ".js",
"EXPERIMENTAL__emitMetadata": false,
"EXPERIMENTAL__emitResolverMap": false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type SomeType {

```ts
import type { GqlScalar } from "grats";
import type { MyString as MyStringInternal } from "./CustomScalarArgument";
import type { MyString as MyStringInternal } from "./CustomScalarArgument.js";
import { GraphQLSchema, GraphQLScalarType, GraphQLObjectType, GraphQLString, GraphQLNonNull } from "graphql";
export type SchemaConfig = {
scalars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type SomeType {

```ts
import type { GqlScalar } from "grats";
import type { MyUrl as MyUrlInternal } from "./DefineCustomScalar";
import type { MyUrl as MyUrlInternal } from "./DefineCustomScalar.js";
import { GraphQLSchema, GraphQLScalarType, GraphQLObjectType, GraphQLString } from "graphql";
export type SchemaConfig = {
scalars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type SomeType {

```ts
import type { GqlScalar } from "grats";
import type { MyUrl as MyUrlInternal } from "./DefineCustomScalarWithDescription";
import type { MyUrl as MyUrlInternal } from "./DefineCustomScalarWithDescription.js";
import { GraphQLSchema, GraphQLScalarType, GraphQLObjectType, GraphQLString } from "graphql";
export type SchemaConfig = {
scalars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type SomeType {

```ts
import type { GqlScalar } from "grats";
import type { MyUrl as CustomNameInternal } from "./DefineRenamedCustomScalar";
import type { MyUrl as CustomNameInternal } from "./DefineRenamedCustomScalar.js";
import { GraphQLSchema, GraphQLScalarType, GraphQLObjectType, GraphQLString } from "graphql";
export type SchemaConfig = {
scalars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ scalar UUID @specifiedBy(url: "https://tools.ietf.org/html/rfc4122")

```ts
import type { GqlScalar } from "grats";
import type { UUID as UUIDInternal } from "./SpecifiedBy";
import type { UUID as UUIDInternal } from "./SpecifiedBy.js";
import { GraphQLSchema, GraphQLScalarType } from "graphql";
export type SchemaConfig = {
scalars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as queryGreetingResolver, createDerivedContext } from "./derivedContextPromiseValid";
import { greeting as queryGreetingResolver, createDerivedContext } from "./derivedContextPromiseValid.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { farewell as queryFarewellResolver, greetingContext, greeting as queryGreetingResolver } from "./derivedContextUsedMultipleTimes";
import { farewell as queryFarewellResolver, greetingContext, greeting as queryGreetingResolver } from "./derivedContextUsedMultipleTimes.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as queryGreetingResolver, createDerivedContext2, createDerivedContext1 } from "./nestedAsyncDerivedContext";
import { greeting as queryGreetingResolver, createDerivedContext2, createDerivedContext1 } from "./nestedAsyncDerivedContext.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as queryGreetingResolver, createDerivedContext } from "./simpleDerivedContext";
import { greeting as queryGreetingResolver, createDerivedContext } from "./simpleDerivedContext.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as queryGreetingResolver, createDerivedContext } from "./simpleDerivedContextNoArgs";
import { greeting as queryGreetingResolver, createDerivedContext } from "./simpleDerivedContextNoArgs.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLDirective, DirectiveLocation, GraphQLNonNull, GraphQLInt, specifiedDirectives, GraphQLObjectType, GraphQLString } from "graphql";
import { likes as queryLikesResolver } from "./directiveOnArgumentDefinition";
import { likes as queryLikesResolver } from "./directiveOnArgumentDefinition.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLDirective, DirectiveLocation, GraphQLNonNull, GraphQLInt, specifiedDirectives, GraphQLObjectType, GraphQLString } from "graphql";
import { likes as queryLikesResolver } from "./directiveOnFieldDefinition";
import { likes as queryLikesResolver } from "./directiveOnFieldDefinition.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ scalar MyScalar @max(foo: 10)

```ts
import type { GqlScalar } from "grats";
import type { MyScalar as MyScalarInternal } from "./directiveOnScalar";
import type { MyScalar as MyScalarInternal } from "./directiveOnScalar.js";
import { GraphQLSchema, GraphQLDirective, DirectiveLocation, GraphQLNonNull, GraphQLInt, specifiedDirectives, GraphQLScalarType } from "graphql";
export type SchemaConfig = {
scalars: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { myQueryField as queryMyQueryFieldResolver } from "./undefinedDirectiveWithoutArgs";
import { myQueryField as queryMyQueryFieldResolver } from "./undefinedDirectiveWithoutArgs.js";
export function getSchema(): GraphQLSchema {
const QueryType: GraphQLObjectType = new GraphQLObjectType({
name: "Query",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/enums/NonNullEnumDefault.ts.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLEnumType } from "graphql";
import { hello as queryHelloResolver } from "./NonNullEnumDefault";
import { hello as queryHelloResolver } from "./NonNullEnumDefault.js";
export function getSchema(): GraphQLSchema {
const GreetingOptionsType: GraphQLEnumType = new GraphQLEnumType({
name: "GreetingOptions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLInputObjectType, GraphQLEnumType } from "graphql";
import { hello as queryHelloResolver } from "./NonNullEnumDefaultInInputObject";
import { hello as queryHelloResolver } from "./NonNullEnumDefaultInInputObject.js";
export function getSchema(): GraphQLSchema {
const GreetingOptionsType: GraphQLEnumType = new GraphQLEnumType({
name: "GreetingOptions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLEnumType } from "graphql";
import { hello as queryHelloResolver } from "./NonNullPluralEnumDefaults";
import { hello as queryHelloResolver } from "./NonNullPluralEnumDefaults.js";
export function getSchema(): GraphQLSchema {
const GreetingOptionsType: GraphQLEnumType = new GraphQLEnumType({
name: "GreetingOptions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLEnumType } from "graphql";
import { hello as queryHelloResolver } from "./NonNullTsEnumDefault";
import { hello as queryHelloResolver } from "./NonNullTsEnumDefault.js";
export function getSchema(): GraphQLSchema {
const GreetingOptionsType: GraphQLEnumType = new GraphQLEnumType({
name: "GreetingOptions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Query {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLEnumType } from "graphql";
import { hello as queryHelloResolver } from "./NonNullTsEnumDefaultStringLiteral";
import { hello as queryHelloResolver } from "./NonNullTsEnumDefaultStringLiteral.js";
export function getSchema(): GraphQLSchema {
const GreetingOptionsType: GraphQLEnumType = new GraphQLEnumType({
name: "GreetingOptions",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/examples/playground.ts.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ type User {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull } from "graphql";
import { getUser as someTypeGetUserResolver } from "./playground";
import { getUser as someTypeGetUserResolver } from "./playground.js";
export function getSchema(): GraphQLSchema {
const UserType: GraphQLObjectType = new GraphQLObjectType({
name: "User",
Expand Down
2 changes: 1 addition & 1 deletion src/tests/fixtures/examples/readme.ts.expected.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type User {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull } from "graphql";
import { me as queryMeResolver, viewer as queryViewerResolver } from "./readme";
import { me as queryMeResolver, viewer as queryViewerResolver } from "./readme.js";
export function getSchema(): GraphQLSchema {
const UserType: GraphQLObjectType = new GraphQLObjectType({
name: "User",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type User implements IPerson {

```ts
import { GraphQLSchema, GraphQLInterfaceType, GraphQLString, GraphQLObjectType } from "graphql";
import { greeting as adminGreetingResolver, greeting as userGreetingResolver } from "./addStringFieldToInterface";
import { greeting as adminGreetingResolver, greeting as userGreetingResolver } from "./addStringFieldToInterface.js";
export function getSchema(): GraphQLSchema {
const IPersonType: GraphQLInterfaceType = new GraphQLInterfaceType({
name: "IPerson",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type User implements IPerson & IThing {

```ts
import { GraphQLSchema, GraphQLInterfaceType, GraphQLString, GraphQLObjectType } from "graphql";
import { greeting as adminGreetingResolver, greeting as userGreetingResolver } from "./addStringFieldToInterfaceImplementedByInterface";
import { greeting as adminGreetingResolver, greeting as userGreetingResolver } from "./addStringFieldToInterfaceImplementedByInterface.js";
export function getSchema(): GraphQLSchema {
const IThingType: GraphQLInterfaceType = new GraphQLInterfaceType({
name: "IThing",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type SomeType {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as someTypeGreetingResolver } from "./addDeprecatedField";
import { greeting as someTypeGreetingResolver } from "./addDeprecatedField.js";
export function getSchema(): GraphQLSchema {
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({
name: "SomeType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type SomeType {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString, GraphQLNonNull } from "graphql";
import { greeting as someTypeGreetingResolver } from "./addFieldWithArguments";
import { greeting as someTypeGreetingResolver } from "./addFieldWithArguments.js";
export function getSchema(): GraphQLSchema {
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({
name: "SomeType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type SomeType {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as someTypeGreetingResolver } from "./addFieldWithDescription";
import { greeting as someTypeGreetingResolver } from "./addFieldWithDescription.js";
export function getSchema(): GraphQLSchema {
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({
name: "SomeType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type SomeType {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as someTypeHelloResolver } from "./addRenamedFieldToSomeType";
import { greeting as someTypeHelloResolver } from "./addRenamedFieldToSomeType.js";
export function getSchema(): GraphQLSchema {
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({
name: "SomeType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type SomeType {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as someTypeGreetingResolver } from "./addStringFieldToSomeType";
import { greeting as someTypeGreetingResolver } from "./addStringFieldToSomeType.js";
export function getSchema(): GraphQLSchema {
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({
name: "SomeType",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type SomeType {
### TypeScript

```ts
import someTypeGreetingResolver from "./defaultExport";
import someTypeGreetingResolver from "./defaultExport.js";
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
export function getSchema(): GraphQLSchema {
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type SomeType {

```ts
import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
import { greeting as someTypeGreetingResolver } from "./fieldAsExportedArrowFunction";
import { greeting as someTypeGreetingResolver } from "./fieldAsExportedArrowFunction.js";
export function getSchema(): GraphQLSchema {
const SomeTypeType: GraphQLObjectType = new GraphQLObjectType({
name: "SomeType",
Expand Down
Loading