Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions examples/apollo-server/Query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IPerson from "./interfaces/IPerson";
import User from "./models/User";
import IPerson from "./interfaces/IPerson.js";
import User from "./models/User.js";

/** @gqlQueryField */
export function person(): IPerson {
Expand Down
2 changes: 1 addition & 1 deletion examples/apollo-server/models/Group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import User from "./User";
import User from "./User.js";

/** @gqlType */
export default class Group {
Expand Down
4 changes: 2 additions & 2 deletions examples/apollo-server/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IPerson from "../interfaces/IPerson";
import Group from "./Group";
import IPerson from "../interfaces/IPerson.js";
import Group from "./Group.js";

/** @gqlType User */
export default class UserResolver implements IPerson {
Expand Down
3 changes: 2 additions & 1 deletion examples/apollo-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "grats-example-apollo-server",
"version": "0.0.0",
"description": "Example server showcasing Grats used with Apollo Server",
"type": "module",
"main": "index.js",
"scripts": {
"start": "tsc && node dist/server.js",
Expand All @@ -28,7 +29,7 @@
"dependencies": {
"@apollo/server": "^5.0.0",
"@types/node": "^20.8.10",
"graphql": "16.11.0"
"graphql": "17.0.0-alpha.11"
},
"devDependencies": {
"grats": "workspace:*",
Expand Down
8 changes: 4 additions & 4 deletions examples/apollo-server/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Do not manually edit. Regenerate by running `npx grats`.
*/

import UserClass from "./models/User";
import queryAllUsersResolver from "./models/User";
import queryMeResolver from "./models/User";
import UserClass from "./models/User.js";
import queryAllUsersResolver from "./models/User.js";
import queryMeResolver from "./models/User.js";
import { GraphQLSchema, GraphQLObjectType, GraphQLNonNull, GraphQLList, GraphQLString, GraphQLInterfaceType } from "graphql";
import { person as queryPersonResolver } from "./Query";
import { person as queryPersonResolver } from "./Query.js";
export function getSchema(): GraphQLSchema {
const GroupType: GraphQLObjectType = new GraphQLObjectType({
name: "Group",
Expand Down
2 changes: 1 addition & 1 deletion examples/apollo-server/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApolloServer } from "@apollo/server";
import { startStandaloneServer } from "@apollo/server/standalone";
import { getSchema } from "./schema";
import { getSchema } from "./schema.js";

async function main() {
const server = new ApolloServer({ schema: getSchema() });
Expand Down
3 changes: 2 additions & 1 deletion examples/apollo-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"grats": {
"nullableByDefault": false
"nullableByDefault": false,
"importModuleSpecifierEnding": ".js"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like all packages need to add this now. Is it time to change the default here? Is this tied to using es modules?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the default to ".js". Since .js extensions work for both CJS and ESM Node.js projects, this is a better default. All example tsconfigs no longer need to set this explicitly.

The one exception is the Next.js example which uses moduleResolution: "bundler" — webpack can't resolve .js to .ts without extra config, so that example sets importModuleSpecifierEnding: "".

},
"compilerOptions": {
"outDir": "dist",
Expand Down
2 changes: 1 addition & 1 deletion examples/express-graphql-http/interfaces/IPerson.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import User from "../models/User";
import User from "../models/User.js";

/** @gqlInterface */
export default interface IPerson {
Expand Down
2 changes: 1 addition & 1 deletion examples/express-graphql-http/models/Group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import User from "./User";
import User from "./User.js";

/** @gqlType */
export default class Group {
Expand Down
4 changes: 2 additions & 2 deletions examples/express-graphql-http/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IPerson from "../interfaces/IPerson";
import Group from "./Group";
import IPerson from "../interfaces/IPerson.js";
import Group from "./Group.js";

/** @gqlType */
export default class User implements IPerson {
Expand Down
3 changes: 2 additions & 1 deletion examples/express-graphql-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "grats-example-express-graphql-http",
"version": "0.0.0",
"description": "Example server showcasing Grats used with Express and graphql-http ",
"type": "module",
"main": "index.js",
"scripts": {
"start": "tsc && node dist/server.js",
Expand Down Expand Up @@ -30,7 +31,7 @@
"@types/express": "^4.17.20",
"@types/node": "^20.8.10",
"express": "^4.18.2",
"graphql": "16.8.1",
"graphql": "17.0.0-alpha.11",
"graphql-http": "^1.22.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions examples/express-graphql-http/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Do not manually edit. Regenerate by running `npx grats`.
*/

import UserClass from "./models/User";
import queryAllUsersResolver from "./models/User";
import queryMeResolver from "./models/User";
import UserClass from "./models/User.js";
import queryAllUsersResolver from "./models/User.js";
import queryMeResolver from "./models/User.js";
import { GraphQLSchema, GraphQLObjectType, GraphQLNonNull, GraphQLList, GraphQLString, GraphQLInterfaceType } from "graphql";
import { person as queryPersonResolver } from "./interfaces/IPerson";
import { person as queryPersonResolver } from "./interfaces/IPerson.js";
export function getSchema(): GraphQLSchema {
const GroupType: GraphQLObjectType = new GraphQLObjectType({
name: "Group",
Expand Down
4 changes: 2 additions & 2 deletions examples/express-graphql-http/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as express from "express";
import express from "express";
import { createHandler } from "graphql-http/lib/use/express";
import { getSchema } from "./schema";
import { getSchema } from "./schema.js";

const app = express();

Expand Down
16 changes: 7 additions & 9 deletions examples/express-graphql-http/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
{
// Most ts-node options can be specified here using their programmatic names.
"ts-node": {
"files": true,
// It is faster to skip typechecking.
// Remove if you want ts-node to do typechecking.
"transpileOnly": false
},
"grats": {
"nullableByDefault": false
"nullableByDefault": false,
"importModuleSpecifierEnding": ".js"
},
"compilerOptions": {
"outDir": "dist",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"target": "esnext",
"lib": ["esnext"],
"strict": true
"strict": true,
"skipLibCheck": true
}
}
3 changes: 2 additions & 1 deletion examples/incremental-migration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "grats-example-migration",
"version": "0.0.0",
"description": "Example server showcasing an incremental migration from Pothos to Grats",
"type": "module",
"main": "index.js",
"scripts": {
"start": "tsc && node dist/server.js",
Expand Down Expand Up @@ -33,7 +34,7 @@
"@faker-js/faker": "^8.4.1",
"@graphql-tools/schema": "^10.0.3",
"@pothos/core": "^3.41.1",
"graphql": "16.8.1",
"graphql": "17.0.0-alpha.11",
"graphql-yoga": "^5.0.0",
"typescript": "^5.5.4"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// DO NOT USE DIRECTLY. Prefer the merged schema in `./mergedSchema.ts`.

import { GraphQLSchema, GraphQLObjectType, GraphQLNonNull, GraphQLString, GraphQLID } from "graphql";
import { user as queryUserResolver } from "./../models";
import { user as queryUserResolver } from "./../models.js";
export function getSchema(): GraphQLSchema {
const UserType: GraphQLObjectType = new GraphQLObjectType({
name: "User",
Expand Down
8 changes: 6 additions & 2 deletions examples/incremental-migration/schemas/mergedSchema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { schema as legacySchema } from "./pothosSchema";
import { getSchema as getGratsSchema } from "./gratsGeneratedSchema";
import { schema as legacySchema } from "./pothosSchema.js";
import { getSchema as getGratsSchema } from "./gratsGeneratedSchema.js";
import { mergeSchemas } from "@graphql-tools/schema";
import { printSchema, lexicographicSortSchema } from "graphql";
import fs from "fs";
import path from "path";
import { fileURLToPath } from "url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

/**
* Merges the Pothos (legacy) and Grats (new) schemas into a single schema for
Expand Down
2 changes: 1 addition & 1 deletion examples/incremental-migration/schemas/pothosSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Users, Posts, Comments, User, Post, Comment } from "../models";
import { Users, Posts, Comments, User, Post, Comment } from "../models.js";
import SchemaBuilder from "@pothos/core";
const builder = new SchemaBuilder({});

Expand Down
2 changes: 1 addition & 1 deletion examples/incremental-migration/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createServer } from "node:http";
import { createYoga } from "graphql-yoga";
import { schema } from "./schemas/mergedSchema";
import { schema } from "./schemas/mergedSchema.js";

const yoga = createYoga({ schema });

Expand Down
1 change: 1 addition & 0 deletions examples/incremental-migration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"grats": {
"nullableByDefault": false,
"importModuleSpecifierEnding": ".js",
"tsSchema": "./schemas/gratsGeneratedSchema.ts",
"graphqlSchema": "gratsSchema.graphql",
"tsSchemaHeader": "// DO NOT USE DIRECTLY. Prefer the merged schema in `./mergedSchema.ts`.",
Expand Down
2 changes: 1 addition & 1 deletion examples/next-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"homepage": "https://github.com/captbaritone/grats#readme",
"dependencies": {
"graphql": "^16.8.1",
"graphql": "17.0.0-alpha.11",
"graphql-yoga": "^5.0.0",
"next": "14.0.3",
"react": "^18",
Expand Down
10 changes: 5 additions & 5 deletions examples/production-app/Database.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PubSub } from "./PubSub";
import { VC } from "./ViewerContext";
import { Like } from "./models/Like";
import { Post } from "./models/Post";
import { User } from "./models/User";
import { PubSub } from "./PubSub.js";
import { VC } from "./ViewerContext.js";
import { Like } from "./models/Like.js";
import { Post } from "./models/Post.js";
import { User } from "./models/User.js";

/**
* This module is intended to represent a database.
Expand Down
8 changes: 4 additions & 4 deletions examples/production-app/ViewerContext.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import DataLoader from "dataloader";
import { getPostsByIds, getUsersByIds, getLikesByIds } from "./Database";
import { getPostsByIds, getUsersByIds, getLikesByIds } from "./Database.js";
import { YogaInitialContext } from "graphql-yoga";
import { Post } from "./models/Post";
import { User } from "./models/User";
import { Like } from "./models/Like";
import { Post } from "./models/Post.js";
import { User } from "./models/User.js";
import { Like } from "./models/Like.js";

/**
* Viewer Context
Expand Down
2 changes: 1 addition & 1 deletion examples/production-app/graphql/CustomScalars.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Kind } from "graphql";
import type { SchemaConfig } from "../schema";
import type { SchemaConfig } from "../schema.js";

// TODO: Consider switching serialization to follow https://ibm.github.io/graphql-specs/custom-scalars/date.html

Expand Down
2 changes: 1 addition & 1 deletion examples/production-app/graphql/Node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fromGlobalId, toGlobalId } from "graphql-relay";
import { ID } from "grats";
import { VC } from "../ViewerContext";
import { VC } from "../ViewerContext.js";

/**
* Converts a globally unique ID into a local ID asserting
Expand Down
2 changes: 1 addition & 1 deletion examples/production-app/graphql/directives.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defaultFieldResolver, GraphQLError, GraphQLSchema } from "graphql";
import { Int } from "grats";
import { Ctx } from "../ViewerContext";
import { Ctx } from "../ViewerContext.js";
import { getDirective, MapperKind, mapSchema } from "@graphql-tools/utils";

/**
Expand Down
16 changes: 8 additions & 8 deletions examples/production-app/models/Like.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as DB from "../Database";
import { VC } from "../ViewerContext";
import { GraphQLNode, getLocalTypeAssert } from "../graphql/Node";
import { User } from "./User";
import { Model } from "./Model";
import { ID } from "../../../dist/src";
import { GqlDate } from "../graphql/CustomScalars";
import { Post } from "./Post";
import * as DB from "../Database.js";
import { VC } from "../ViewerContext.js";
import { GraphQLNode, getLocalTypeAssert } from "../graphql/Node.js";
import { User } from "./User.js";
import { Model } from "./Model.js";
import { ID } from "../../../dist/src/index.js";
import { GqlDate } from "../graphql/CustomScalars.js";
import { Post } from "./Post.js";

/**
* A reaction from a user indicating that they like a post.
Expand Down
12 changes: 6 additions & 6 deletions examples/production-app/models/LikeConnection.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { GqlInfo, Int } from "grats";
import * as DB from "../Database";
import { VC } from "../ViewerContext";
import { Like } from "./Like";
import { PageInfo } from "../graphql/Connection";
import { PubSub } from "../PubSub";
import * as DB from "../Database.js";
import { VC } from "../ViewerContext.js";
import { Like } from "./Like.js";
import { PageInfo } from "../graphql/Connection.js";
import { PubSub } from "../PubSub.js";
import { filter, map, pipe } from "graphql-yoga";
import { getLocalTypeAssert } from "../graphql/Node";
import { getLocalTypeAssert } from "../graphql/Node.js";
import { connectionFromSelectOrCount } from "../graphql/gqlUtils.js";

/** @gqlType */
Expand Down
2 changes: 1 addition & 1 deletion examples/production-app/models/Model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VC } from "../ViewerContext";
import { VC } from "../ViewerContext.js";

/**
* Generic model class built around a database row
Expand Down
16 changes: 8 additions & 8 deletions examples/production-app/models/Post.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as DB from "../Database";
import { VC } from "../ViewerContext";
import { GraphQLNode, getLocalTypeAssert } from "../graphql/Node";
import { User } from "./User";
import { Model } from "./Model";
import { GqlInfo, ID, Int } from "../../../dist/src";
import { GqlDate } from "../graphql/CustomScalars";
import { LikeConnection } from "./LikeConnection";
import * as DB from "../Database.js";
import { VC } from "../ViewerContext.js";
import { GraphQLNode, getLocalTypeAssert } from "../graphql/Node.js";
import { User } from "./User.js";
import { Model } from "./Model.js";
import { GqlInfo, ID, Int } from "../../../dist/src/index.js";
import { GqlDate } from "../graphql/CustomScalars.js";
import { LikeConnection } from "./LikeConnection.js";
import { connectionFromSelectOrCount } from "../graphql/gqlUtils.js";

/**
Expand Down
8 changes: 4 additions & 4 deletions examples/production-app/models/PostConnection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GqlInfo, Int } from "grats";
import * as DB from "../Database";
import { VC } from "../ViewerContext";
import { Post } from "./Post";
import { Connection } from "../graphql/Connection";
import * as DB from "../Database.js";
import { VC } from "../ViewerContext.js";
import { Post } from "./Post.js";
import { Connection } from "../graphql/Connection.js";
import { connectionFromSelectOrCount } from "../graphql/gqlUtils.js";

/**
Expand Down
12 changes: 6 additions & 6 deletions examples/production-app/models/User.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as DB from "../Database";
import { VC } from "../ViewerContext";
import { GraphQLNode } from "../graphql/Node";
import { Model } from "./Model";
import { Post } from "./Post";
import { Connection } from "../graphql/Connection";
import * as DB from "../Database.js";
import { VC } from "../ViewerContext.js";
import { GraphQLNode } from "../graphql/Node.js";
import { Model } from "./Model.js";
import { Post } from "./Post.js";
import { Connection } from "../graphql/Connection.js";
import { GqlInfo, Int } from "../../../dist/src/Types.js";
import { connectionFromSelectOrCount } from "../graphql/gqlUtils.js";

Expand Down
8 changes: 4 additions & 4 deletions examples/production-app/models/UserConnection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { GqlInfo, Int } from "grats";
import * as DB from "../Database";
import { VC } from "../ViewerContext";
import { User } from "./User";
import { Connection } from "../graphql/Connection";
import * as DB from "../Database.js";
import { VC } from "../ViewerContext.js";
import { User } from "./User.js";
import { Connection } from "../graphql/Connection.js";
import { connectionFromSelectOrCount } from "../graphql/gqlUtils.js";

/**
Expand Down
Loading