Skip to content

Commit

Permalink
'fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AVtheking committed Jan 28, 2024
1 parent 9a1f184 commit 5c755a9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
3 changes: 1 addition & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,6 @@ type Query {
organizationsMemberConnection(first: Int, orderBy: UserOrderByInput, orgId: ID!, skip: Int, where: UserWhereInput): UserConnection!
plugin(orgId: ID!): [Plugin]
post(id: ID!): Post
postByUser(userId: ID!): [Post]
postsByOrganization(id: ID!, orderBy: PostOrderByInput): [Post]
postsByOrganizationConnection(first: Int, id: ID!, orderBy: PostOrderByInput, skip: Int, where: PostWhereInput): PostConnection
registeredEventsByUser(id: ID, orderBy: EventOrderByInput): [Event]
Expand Down Expand Up @@ -984,7 +983,7 @@ type User {
organizationsBlockedBy: [Organization]
phone: UserPhone
pluginCreationAllowed: Boolean!
post: Post
post: [Post]
registeredEvents: [Event]
tagsAssignedWith(after: String, before: String, first: PositiveInt, last: PositiveInt, organizationId: ID): UserTagsConnection
tokenVersion: Int!
Expand Down
16 changes: 15 additions & 1 deletion src/resolvers/User/post.ts
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
export const post
import { Post } from "../../models";
import type { UserResolvers } from "../../types/generatedGraphQLTypes";
/**
* This resolver function will fetch and return the post created by the user from database.
* @param parent - An object that is the return value of the resolver for this field's parent.
* @returns An array which conatins the post created by the user.
*/

export const post: UserResolvers["post"] = async (parent) => {
const post = await Post.find({
createrId: parent._id,
}).lean();

return post;
};
1 change: 0 additions & 1 deletion src/typeDefs/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export const queries = gql`
post(id: ID!): Post
postsByOrganization(id: ID!, orderBy: PostOrderByInput): [Post]
postByUser(userId: ID!): [Post]
postsByOrganizationConnection(
id: ID!
Expand Down
2 changes: 1 addition & 1 deletion src/typeDefs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export const types = gql`
educationGrade: EducationGrade
email: EmailAddress!
employmentStatus: EmploymentStatus
post: Post
post: [Post]
eventAdmin: [Event]
firstName: String!
gender: Gender
Expand Down
11 changes: 2 additions & 9 deletions src/types/generatedGraphQLTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,6 @@ export type Query = {
organizationsMemberConnection: UserConnection;
plugin?: Maybe<Array<Maybe<Plugin>>>;
post?: Maybe<Post>;
postByUser?: Maybe<Array<Maybe<Post>>>;
postsByOrganization?: Maybe<Array<Maybe<Post>>>;
postsByOrganizationConnection?: Maybe<PostConnection>;
registeredEventsByUser?: Maybe<Array<Maybe<Event>>>;
Expand Down Expand Up @@ -1473,11 +1472,6 @@ export type QueryPostArgs = {
};


export type QueryPostByUserArgs = {
userId: Scalars['ID']['input'];
};


export type QueryPostsByOrganizationArgs = {
id: Scalars['ID']['input'];
orderBy?: InputMaybe<PostOrderByInput>;
Expand Down Expand Up @@ -1675,7 +1669,7 @@ export type User = {
organizationsBlockedBy?: Maybe<Array<Maybe<Organization>>>;
phone?: Maybe<UserPhone>;
pluginCreationAllowed: Scalars['Boolean']['output'];
post?: Maybe<Post>;
post?: Maybe<Array<Maybe<Post>>>;
registeredEvents?: Maybe<Array<Maybe<Event>>>;
tagsAssignedWith?: Maybe<UserTagsConnection>;
tokenVersion: Scalars['Int']['output'];
Expand Down Expand Up @@ -2794,7 +2788,6 @@ export type QueryResolvers<ContextType = any, ParentType extends ResolversParent
organizationsMemberConnection?: Resolver<ResolversTypes['UserConnection'], ParentType, ContextType, RequireFields<QueryOrganizationsMemberConnectionArgs, 'orgId'>>;
plugin?: Resolver<Maybe<Array<Maybe<ResolversTypes['Plugin']>>>, ParentType, ContextType, RequireFields<QueryPluginArgs, 'orgId'>>;
post?: Resolver<Maybe<ResolversTypes['Post']>, ParentType, ContextType, RequireFields<QueryPostArgs, 'id'>>;
postByUser?: Resolver<Maybe<Array<Maybe<ResolversTypes['Post']>>>, ParentType, ContextType, RequireFields<QueryPostByUserArgs, 'userId'>>;
postsByOrganization?: Resolver<Maybe<Array<Maybe<ResolversTypes['Post']>>>, ParentType, ContextType, RequireFields<QueryPostsByOrganizationArgs, 'id'>>;
postsByOrganizationConnection?: Resolver<Maybe<ResolversTypes['PostConnection']>, ParentType, ContextType, RequireFields<QueryPostsByOrganizationConnectionArgs, 'id'>>;
registeredEventsByUser?: Resolver<Maybe<Array<Maybe<ResolversTypes['Event']>>>, ParentType, ContextType, Partial<QueryRegisteredEventsByUserArgs>>;
Expand Down Expand Up @@ -2871,7 +2864,7 @@ export type UserResolvers<ContextType = any, ParentType extends ResolversParentT
organizationsBlockedBy?: Resolver<Maybe<Array<Maybe<ResolversTypes['Organization']>>>, ParentType, ContextType>;
phone?: Resolver<Maybe<ResolversTypes['UserPhone']>, ParentType, ContextType>;
pluginCreationAllowed?: Resolver<ResolversTypes['Boolean'], ParentType, ContextType>;
post?: Resolver<Maybe<ResolversTypes['Post']>, ParentType, ContextType>;
post?: Resolver<Maybe<Array<Maybe<ResolversTypes['Post']>>>, ParentType, ContextType>;
registeredEvents?: Resolver<Maybe<Array<Maybe<ResolversTypes['Event']>>>, ParentType, ContextType>;
tagsAssignedWith?: Resolver<Maybe<ResolversTypes['UserTagsConnection']>, ParentType, ContextType, Partial<UserTagsAssignedWithArgs>>;
tokenVersion?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
Expand Down

0 comments on commit 5c755a9

Please sign in to comment.