Skip to content

Commit

Permalink
fixes related to rename input and object types (#1789)
Browse files Browse the repository at this point in the history
  • Loading branch information
lolopinto authored Mar 3, 2024
1 parent 1f99850 commit d1e4f3f
Show file tree
Hide file tree
Showing 19 changed files with 492 additions and 46 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/ent-rsvp/backend/src/graphql/generated/schema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/ent-rsvp/backend/src/graphql/mutations/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RequestContext, loadRow, query } from "@snowtop/ent";
import { gqlContextType, gqlMutation, gqlQuery } from "@snowtop/ent/graphql";
import { useAndVerifyAuthJWT } from "@snowtop/ent-passport";
import { Guest, User } from "src/ent";
import { ViewerType } from "../../resolvers/viewer_type";
import { GraphQLViewer } from "../../resolvers/viewer_type";
import { GraphQLString } from "graphql";
import {
AuthGuestInput,
Expand Down Expand Up @@ -58,7 +58,7 @@ export class AuthResolver {
if (!viewer) {
throw new Error(`could not log user in with given credentials`);
}
return new AuthGuestPayload(token, new ViewerType(viewer));
return new AuthGuestPayload(token, new GraphQLViewer(viewer));
}

@gqlQuery({
Expand Down Expand Up @@ -141,6 +141,6 @@ export class AuthResolver {
throw new Error(`not the right credentials`);
}

return new AuthUserPayload(token, new ViewerType(viewer));
return new AuthUserPayload(token, new GraphQLViewer(viewer));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
gqlField,
gqlObjectType,
} from "@snowtop/ent/graphql";
import { ViewerType } from "../../resolvers/viewer_type";
import { GraphQLViewer } from "../../resolvers/viewer_type";
import { GraphQLString } from "graphql";

@gqlInputObjectType()
Expand All @@ -30,11 +30,11 @@ export class AuthGuestPayload {

@gqlField({
class: "AuthGuestPayload",
type: ViewerType,
type: GraphQLViewer,
})
viewer: ViewerType = new ViewerType(new LoggedOutViewer());
viewer: GraphQLViewer = new GraphQLViewer(new LoggedOutViewer());

constructor(token: string, viewer: ViewerType) {
constructor(token: string, viewer: GraphQLViewer) {
this.token = token;
this.viewer = viewer;
}
Expand Down Expand Up @@ -65,11 +65,11 @@ export class AuthUserPayload {

@gqlField({
class: "AuthUserPayload",
type: ViewerType,
type: GraphQLViewer,
})
viewer: ViewerType = new ViewerType(new LoggedOutViewer());
viewer: GraphQLViewer = new GraphQLViewer(new LoggedOutViewer());

constructor(token: string, viewer: ViewerType) {
constructor(token: string, viewer: GraphQLViewer) {
this.token = token;
this.viewer = viewer;
}
Expand Down
8 changes: 4 additions & 4 deletions examples/ent-rsvp/backend/src/graphql/resolvers/viewer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { gqlContextType, gqlQuery } from "@snowtop/ent/graphql";
import { RequestContext } from "@snowtop/ent";
import { ViewerType } from "./viewer_type";
import { GraphQLViewer } from "./viewer_type";

export default class ViewerResolver {
@gqlQuery({
class: "ViewerResolver",
name: "viewer",
type: ViewerType,
type: GraphQLViewer,
nullable: true,
args: [gqlContextType()],
})
viewer(context: RequestContext): ViewerType {
return new ViewerType(context.getViewer());
viewer(context: RequestContext): GraphQLViewer {
return new GraphQLViewer(context.getViewer());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { gqlField, gqlObjectType } from "@snowtop/ent/graphql";
import { Viewer } from "@snowtop/ent";
import { Guest, User } from "src/ent/";

// TODO we should expecially throw for "Viewer"
@gqlObjectType({ name: "Viewer" })
export class ViewerType {
export class GraphQLViewer {
constructor(private viewer: Viewer) {}

@gqlField({
class: "ViewerType",
class: "GraphQLViewer",
type: User,
nullable: true,
async: true,
Expand All @@ -21,7 +22,7 @@ export class ViewerType {
}

@gqlField({
class: "ViewerType",
class: "GraphQLViewer",
type: Guest,
nullable: true,
async: true,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/simple/src/graphql/generated/schema.gql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions examples/simple/src/graphql/generated/schema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d1e4f3f

Please sign in to comment.