Skip to content

Commit

Permalink
update graphql in example
Browse files Browse the repository at this point in the history
  • Loading branch information
lolopinto committed Sep 21, 2021
1 parent 19f3369 commit e493bd5
Show file tree
Hide file tree
Showing 14 changed files with 565 additions and 30 deletions.
34 changes: 17 additions & 17 deletions examples/simple/src/ent/generated/patterns/feedback_query_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ import {
UserToSelfContactQuery,
} from "../../internal";

export const objectToCommentsCountLoaderFactory =
new AssocEdgeCountLoaderFactory(EdgeType.ObjectToComments);
export const objectToCommentsDataLoaderFactory = new AssocEdgeLoaderFactory(
EdgeType.ObjectToComments,
() => ObjectToCommentsEdge,
);

export const objectToLikersCountLoaderFactory = new AssocEdgeCountLoaderFactory(
EdgeType.ObjectToLikers,
);
Expand All @@ -38,29 +45,22 @@ export const objectToLikersDataLoaderFactory = new AssocEdgeLoaderFactory(
() => ObjectToLikersEdge,
);

export const objectToCommentsCountLoaderFactory =
new AssocEdgeCountLoaderFactory(EdgeType.ObjectToComments);
export const objectToCommentsDataLoaderFactory = new AssocEdgeLoaderFactory(
EdgeType.ObjectToComments,
() => ObjectToCommentsEdge,
);

export class ObjectToLikersQueryBase extends AssocEdgeQueryBase<
export class ObjectToCommentsQueryBase extends AssocEdgeQueryBase<
Ent,
User,
ObjectToLikersEdge
ObjectToCommentsEdge
> {
constructor(viewer: Viewer, src: EdgeQuerySource<Ent>) {
super(
viewer,
src,
objectToLikersCountLoaderFactory,
objectToLikersDataLoaderFactory,
objectToCommentsCountLoaderFactory,
objectToCommentsDataLoaderFactory,
User.loaderOptions(),
);
}

static query<T extends ObjectToLikersQueryBase>(
static query<T extends ObjectToCommentsQueryBase>(
this: new (viewer: Viewer, src: EdgeQuerySource<Ent>) => T,
viewer: Viewer,
src: EdgeQuerySource<Ent>,
Expand Down Expand Up @@ -117,22 +117,22 @@ export class ObjectToLikersQueryBase extends AssocEdgeQueryBase<
}
}

export class ObjectToCommentsQueryBase extends AssocEdgeQueryBase<
export class ObjectToLikersQueryBase extends AssocEdgeQueryBase<
Ent,
User,
ObjectToCommentsEdge
ObjectToLikersEdge
> {
constructor(viewer: Viewer, src: EdgeQuerySource<Ent>) {
super(
viewer,
src,
objectToCommentsCountLoaderFactory,
objectToCommentsDataLoaderFactory,
objectToLikersCountLoaderFactory,
objectToLikersDataLoaderFactory,
User.loaderOptions(),
);
}

static query<T extends ObjectToCommentsQueryBase>(
static query<T extends ObjectToLikersQueryBase>(
this: new (viewer: Viewer, src: EdgeQuerySource<Ent>) => T,
viewer: Viewer,
src: EdgeQuerySource<Ent>,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright whaa whaa
* Generated by github.com/lolopinto/ent/ent, DO NOT EDIT.
*/

import { GraphQLObjectType } from "graphql";
import { GraphQLConnectionType } from "@snowtop/ent/graphql";
import { ContactToCommentsEdge } from "../../../../ent";
import { UserType } from "../../internal";

var connType: GraphQLConnectionType<GraphQLObjectType, ContactToCommentsEdge>;

export const ContactToCommentsConnectionType = () => {
if (connType === undefined) {
connType = new GraphQLConnectionType("ContactToCommentsQuery", UserType);
}
return connType;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright whaa whaa
* Generated by github.com/lolopinto/ent/ent, DO NOT EDIT.
*/

import { GraphQLObjectType } from "graphql";
import { GraphQLConnectionType } from "@snowtop/ent/graphql";
import { ContactToLikersEdge } from "../../../../ent";
import { UserType } from "../../internal";

var connType: GraphQLConnectionType<GraphQLObjectType, ContactToLikersEdge>;

export const ContactToLikersConnectionType = () => {
if (connType === undefined) {
connType = new GraphQLConnectionType("ContactToLikersQuery", UserType);
}
return connType;
};
77 changes: 74 additions & 3 deletions examples/simple/src/graphql/resolvers/generated/contact_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,27 @@
import {
GraphQLFieldConfigMap,
GraphQLID,
GraphQLInt,
GraphQLNonNull,
GraphQLObjectType,
GraphQLString,
} from "graphql";
import { RequestContext } from "@snowtop/ent";
import { GraphQLNodeInterface, nodeIDEncoder } from "@snowtop/ent/graphql";
import { Contact } from "../../../ent";
import { UserType } from "../internal";
import {
GraphQLEdgeConnection,
GraphQLNodeInterface,
nodeIDEncoder,
} from "@snowtop/ent/graphql";
import {
Contact,
ContactToCommentsQuery,
ContactToLikersQuery,
} from "../../../ent";
import {
ContactToCommentsConnectionType,
ContactToLikersConnectionType,
UserType,
} from "../internal";

export const ContactType = new GraphQLObjectType({
name: "Contact",
Expand All @@ -37,6 +50,64 @@ export const ContactType = new GraphQLObjectType({
lastName: {
type: GraphQLNonNull(GraphQLString),
},
comments: {
type: GraphQLNonNull(ContactToCommentsConnectionType()),
args: {
first: {
description: "",
type: GraphQLInt,
},
after: {
description: "",
type: GraphQLString,
},
last: {
description: "",
type: GraphQLInt,
},
before: {
description: "",
type: GraphQLString,
},
},
resolve: (contact: Contact, args: {}, context: RequestContext) => {
return new GraphQLEdgeConnection(
contact.viewer,
contact,
(v, contact: Contact) => ContactToCommentsQuery.query(v, contact),
args,
);
},
},
likers: {
type: GraphQLNonNull(ContactToLikersConnectionType()),
args: {
first: {
description: "",
type: GraphQLInt,
},
after: {
description: "",
type: GraphQLString,
},
last: {
description: "",
type: GraphQLInt,
},
before: {
description: "",
type: GraphQLString,
},
},
resolve: (contact: Contact, args: {}, context: RequestContext) => {
return new GraphQLEdgeConnection(
contact.viewer,
contact,
(v, contact: Contact) => ContactToLikersQuery.query(v, contact),
args,
);
},
},
fullName: {
type: GraphQLNonNull(GraphQLString),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright whaa whaa
* Generated by github.com/lolopinto/ent/ent, DO NOT EDIT.
*/

import { GraphQLObjectType } from "graphql";
import { GraphQLConnectionType } from "@snowtop/ent/graphql";
import { UserToCommentsEdge } from "../../../../ent";
import { UserType } from "../../internal";

var connType: GraphQLConnectionType<GraphQLObjectType, UserToCommentsEdge>;

export const UserToCommentsConnectionType = () => {
if (connType === undefined) {
connType = new GraphQLConnectionType("UserToCommentsQuery", UserType);
}
return connType;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright whaa whaa
* Generated by github.com/lolopinto/ent/ent, DO NOT EDIT.
*/

import { GraphQLObjectType } from "graphql";
import { GraphQLConnectionType } from "@snowtop/ent/graphql";
import { UserToLikersEdge } from "../../../../ent";
import { UserType } from "../../internal";

var connType: GraphQLConnectionType<GraphQLObjectType, UserToLikersEdge>;

export const UserToLikersConnectionType = () => {
if (connType === undefined) {
connType = new GraphQLConnectionType("UserToLikersQuery", UserType);
}
return connType;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright whaa whaa
* Generated by github.com/lolopinto/ent/ent, DO NOT EDIT.
*/

import { GraphQLObjectType } from "graphql";
import {
GraphQLConnectionType,
GraphQLNodeInterface,
} from "@snowtop/ent/graphql";
import { UserToLikesEdge } from "../../../../ent";

var connType: GraphQLConnectionType<GraphQLObjectType, UserToLikesEdge>;

export const UserToLikesConnectionType = () => {
if (connType === undefined) {
connType = new GraphQLConnectionType(
"UserToLikes",

GraphQLNodeInterface,
);
}
return connType;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright whaa whaa
* Generated by github.com/lolopinto/ent/ent, DO NOT EDIT.
*/

import { GraphQLObjectType } from "graphql";
import {
GraphQLConnectionType,
GraphQLNodeInterface,
} from "@snowtop/ent/graphql";
import { UserToPostEdge } from "../../../../ent";

var connType: GraphQLConnectionType<GraphQLObjectType, UserToPostEdge>;

export const UserToPostConnectionType = () => {
if (connType === undefined) {
connType = new GraphQLConnectionType(
"UserToPost",

GraphQLNodeInterface,
);
}
return connType;
};
Loading

0 comments on commit e493bd5

Please sign in to comment.