{"id":14975952,"url":"https://github.com/basemax/instagramgraphqlapi","last_synced_at":"2025-04-06T13:48:31.566Z","repository":{"id":179985867,"uuid":"654307960","full_name":"BaseMax/InstagramGraphQLAPI","owner":"BaseMax","description":"This GraphQL API is built using Nest.js and TypeScript, providing access to various features and functionalities. The API follows the GraphQL schema-first approach, where the schema is defined using the GraphQL schema language. The server implementation utilizes Nest.js for routing and handling GraphQL requests.","archived":false,"fork":false,"pushed_at":"2025-03-10T16:45:15.000Z","size":620,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T04:17:28.666Z","etag":null,"topics":["graphql","graphql-api","graphql-client","graphql-server","javascript","js","nest-typescript","nestjs","ts","ts-graphql","ts-nest","typescript","typescript-graphql","typescript-nest"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BaseMax.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-15T20:58:59.000Z","updated_at":"2025-03-10T16:45:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"9ce48903-8594-4500-8d71-e2f378f06c98","html_url":"https://github.com/BaseMax/InstagramGraphQLAPI","commit_stats":{"total_commits":28,"total_committers":3,"mean_commits":9.333333333333334,"dds":0.4642857142857143,"last_synced_commit":"b2f195e55a41d5a3a064c2a24e112b8837b9f2a1"},"previous_names":["basemax/instagramgraphqlapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FInstagramGraphQLAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FInstagramGraphQLAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FInstagramGraphQLAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BaseMax%2FInstagramGraphQLAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BaseMax","download_url":"https://codeload.github.com/BaseMax/InstagramGraphQLAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247492520,"owners_count":20947544,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","graphql-api","graphql-client","graphql-server","javascript","js","nest-typescript","nestjs","ts","ts-graphql","ts-nest","typescript","typescript-graphql","typescript-nest"],"created_at":"2024-09-24T13:52:55.964Z","updated_at":"2025-04-06T13:48:31.541Z","avatar_url":"https://github.com/BaseMax.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL API with Nest.js and TypeScript\n\nThis GraphQL API is built using Nest.js and TypeScript, providing access to various features and functionalities. The API follows the GraphQL schema-first approach, where the schema is defined using the GraphQL schema language. The server implementation utilizes Nest.js for routing and handling GraphQL requests.\n\n## Prerequisites\n\n- Node.js (version X.X.X)\n- Yarn (optional, but recommended)\n\n## Getting Started\n\n1. Clone the repository:\n\n```shell\ngit clone https://github.com/BaseMax/InstagramGraphQLAPI.git\n```\n\nInstall the dependencies:\n\n```shell\ncd InstagramGraphQLAPI\nyarn install\n```\n\nStart the development server:\n\n```shell\nyarn dev\n```\n\nAccess the API at http://localhost:3000/api/graphql\n\n## Authentication\n\nThis API uses token-based authentication. To access protected endpoints, include an Authorization header in your requests with the value `Bearer YOUR_TOKEN`.\n\n## Features\n\n**User Authentication:**\n\n- User registration\n- User login\n- User logout\n- Password reset/forgot password\n\n**User Profile:**\n\n- Retrieve user profile\n- Update user profile (name, bio, profile picture)\n- Follow/unfollow users\n- List followers and following\n\n**Posts:**\n\n- Create a new post\n- Retrieve a single post\n- Retrieve posts by user\n- Retrieve posts in the user's feed (from followed users)\n- Like/unlike a post\n- Comment on a post\n- Delete a post (by the owner)\n\n**Explore:**\n\n- Retrieve popular posts\n- Retrieve posts based on hashtags or tags\n- Search for users by username or name\n\n**Notifications:**\n\n- Retrieve notifications for the user (likes, comments, follows)\n- Mark notifications as read\n\n**Direct Messaging:**\n\n- Send a direct message to a user\n- Retrieve direct message conversations\n- Mark messages as read\n\n### Queries\n\n- RetrieveUser: Retrieve a user's profile information\n- RetrievePost: Retrieve a single post by its ID\n- RetrieveUserPosts: Retrieve posts created by a specific user\n- RetrieveFeed: Retrieve posts from the users the current user follows\n- RetrievePopularPosts: Retrieve popular posts based on likes or comments\n- SearchUsers: Search for users based on username or name\n- RetrieveNotifications: Retrieve notifications for the current user\n- RetrieveDirectMessages: Retrieve direct message conversations for the current user\n\n### Mutations\n- CreateUser: Create a new user\n- LoginUser: Authenticate and log in a user\n- LogoutUser: Log out the current user\n- UpdateUserProfile: Update the current user's profile information\n- FollowUser: Follow another user\n- UnfollowUser: Unfollow a previously followed user\n- CreatePost: Create a new post\n- LikePost: Like a post\n- UnlikePost: Remove a like from a post\n- CommentOnPost: Add a comment to a post\n- DeletePost: Delete a post\n- SendMessage: Send a direct message to another user\n- MarkNotificationAsRead: Mark a notification as read\n- MarkMessageAsRead: Mark a direct message as read\n\n## Examples\n\n**User Registration Mutation:**\n\n```graphql\nmutation CreateUser($input: CreateUserInput!) {\n  createUser(input: $input) {\n    id\n    username\n    name\n  }\n}\n```\n\n**User Login Mutation:**\n\n```graphql\nmutation LoginUser($input: LoginUserInput!) {\n  loginUser(input: $input) {\n    token\n  }\n}\n```\n\n**Get User Profile Query:**\n\n```graphql\nquery GetUserProfile($userId: ID!) {\n  userProfile(userId: $userId) {\n    id\n    username\n    name\n    bio\n    profilePicture\n    followersCount\n    followingCount\n    postsCount\n    followers {\n      id\n      username\n    }\n    following {\n      id\n      username\n    }\n  }\n}\n```\n\n**Follow User Mutation:**\n\n```graphql\nmutation FollowUser($userId: ID!) {\n  followUser(userId: $userId) {\n    id\n    username\n  }\n}\n```\n\n**Unfollow User Mutation:**\n\n```graphql\nmutation UnfollowUser($userId: ID!) {\n  unfollowUser(userId: $userId) {\n    id\n    username\n  }\n}\n```\n\n**Get User's Followers Query:**\n\n```graphql\nquery GetUserFollowers($userId: ID!) {\n  userFollowers(userId: $userId) {\n    id\n    username\n    name\n    profilePicture\n  }\n}\n```\n\n**Get User's Following Query:**\n\n```graphql\nquery GetUserFollowing($userId: ID!) {\n  userFollowing(userId: $userId) {\n    id\n    username\n    name\n    profilePicture\n  }\n}\n```\n\n**Get User's Feed Query:**\n\n```graphql\nquery GetUserFeed {\n  userFeed {\n    id\n    caption\n    imageUrl\n    likesCount\n    commentsCount\n    createdAt\n    user {\n      id\n      username\n      name\n      profilePicture\n    }\n  }\n}\n```\n\n**Get Post Query:**\n\n```graphql\nquery GetPost($postId: ID!) {\n  post(postId: $postId) {\n    id\n    caption\n    imageUrl\n    likesCount\n    commentsCount\n    createdAt\n    user {\n      id\n      username\n      name\n      profilePicture\n    }\n  }\n}\n```\n\n**Search Users Query:**\n\n```graphql\nquery SearchUsers($query: String!) {\n  searchUsers(query: $query) {\n    id\n    username\n    name\n    profilePicture\n  }\n}\n```\n\n**Create Post Mutation:**\n\n```graphql\nmutation CreatePost($input: CreatePostInput!) {\n  createPost(input: $input) {\n    id\n    caption\n    imageUrl\n    likesCount\n    commentsCount\n    createdAt\n    user {\n      id\n      username\n      name\n      profilePicture\n    }\n  }\n}\n```\n\n**Like Post Mutation:**\n\n```graphql\nmutation LikePost($postId: ID!) {\n  likePost(postId: $postId) {\n    id\n    likesCount\n  }\n}\n```\n\n**Unlike Post Mutation:**\n\n```graphql\nmutation UnlikePost($postId: ID!) {\n  unlikePost(postId: $postId) {\n    id\n    likesCount\n  }\n}\n```\n\n**Comment on Post Mutation:**\n\n```graphql\nmutation CommentOnPost($postId: ID!, $text: String!) {\n  commentOnPost(postId: $postId, text: $text) {\n    id\n    text\n    createdAt\n    user {\n      id\n      username\n      name\n      profilePicture\n    }\n  }\n}\n```\n\n**Delete Post Mutation:**\n\n```graphql\nmutation DeletePost($postId: ID!) {\n  deletePost(postId: $postId) {\n    id\n  }\n}\n```\n\n**Retrieve Notifications Query:**\n\n```graphql\nquery RetrieveNotifications {\n  notifications {\n    id\n    type\n    createdAt\n    user {\n      id\n      username\n      name\n      profilePicture\n    }\n    post {\n      id\n      caption\n      imageUrl\n    }\n  }\n}\n```\n\n**Send Direct Message Mutation:**\n\n```graphql\nmutation SendDirectMessage($recipientId: ID!, $text: String!) {\n  sendDirectMessage(recipientId: $recipientId, text: $text) {\n    id\n    text\n    createdAt\n    sender {\n      id\n      username\n      name\n      profilePicture\n    }\n    recipient {\n      id\n      username\n      name\n      profilePicture\n    }\n  }\n}\n```\n\n**Retrieve Direct Messages Query:**\n\n```graphql\nquery RetrieveDirectMessages {\n  directMessages {\n    id\n    text\n    createdAt\n    sender {\n      id\n      username\n      name\n      profilePicture\n    }\n    recipient {\n      id\n      username\n      name\n      profilePicture\n    }\n  }\n}\n```\n\nThese examples cover various features such as user registration, login, profile retrieval, follow/unfollow functionality, fetching followers and following users, getting the user's feed, retrieving a post, and searching for users. Remember to customize the variables and adjust the schema and resolvers accordingly to match your specific implementation.\n\n### Auto Testing\n\nHere's an example of a test script in TypeScript using the Jest testing framework to test the GraphQL queries and mutations for an Instagram clone API:\n\n```typescript\nimport axios from 'axios';\n\nconst API_URL = 'http://your-api-endpoint';\n\ndescribe('Instagram Clone API Tests', () =\u003e {\n  let authToken: string;\n\n  beforeAll(async () =\u003e {\n    // Authenticate and obtain the auth token\n    const response = await axios.post(`${API_URL}/login`, {\n      username: 'john_doe',\n      password: 'password',\n    });\n    authToken = response.data.token;\n  });\n\n  it('should retrieve user profile', async () =\u003e {\n    const response = await axios.post(\n      `${API_URL}/graphql`,\n      {\n        query: `\n          query {\n            userProfile(userId: \"user_id\") {\n              id\n              username\n              name\n              bio\n              profilePicture\n              followersCount\n              followingCount\n            }\n          }\n        `,\n      },\n      {\n        headers: {\n          Authorization: `Bearer ${authToken}`,\n        },\n      }\n    );\n\n    expect(response.status).toBe(200);\n    expect(response.data.data.userProfile).toBeDefined();\n    expect(response.data.data.userProfile.username).toBe('john_doe');\n  });\n\n  it('should follow a user', async () =\u003e {\n    const response = await axios.post(\n      `${API_URL}/graphql`,\n      {\n        query: `\n          mutation {\n            followUser(userId: \"user_id\") {\n              id\n              username\n            }\n          }\n        `,\n      },\n      {\n        headers: {\n          Authorization: `Bearer ${authToken}`,\n        },\n      }\n    );\n\n    expect(response.status).toBe(200);\n    expect(response.data.data.followUser).toBeDefined();\n    expect(response.data.data.followUser.username).toBe('user_to_follow');\n  });\n\n  it('should create a post', async () =\u003e {\n    const response = await axios.post(\n      `${API_URL}/graphql`,\n      {\n        query: `\n          mutation {\n            createPost(input: { caption: \"My first post\", imageUrl: \"image_url\" }) {\n              id\n              caption\n              imageUrl\n              likesCount\n              commentsCount\n              createdAt\n              user {\n                id\n                username\n              }\n            }\n          }\n        `,\n      },\n      {\n        headers: {\n          Authorization: `Bearer ${authToken}`,\n        },\n      }\n    );\n\n    expect(response.status).toBe(200);\n    expect(response.data.data.createPost).toBeDefined();\n    expect(response.data.data.createPost.caption).toBe('My first post');\n    expect(response.data.data.createPost.user.username).toBe('john_doe');\n  });\n\n  // Add more tests for other queries and mutations\n\n});\n```\n\nIn this example, we're using Jest and Axios to send requests to the GraphQL API and assert the expected responses. The beforeAll block authenticates the user and obtains an auth token, which is then included in the headers of subsequent requests.\n\nYou can add more tests for other queries and mutations by following a similar structure. Modify the queries/mutations, assertions, and provide the necessary variables for each test case.\n\nRemember to replace http://your-api-endpoint with the actual URL of your GraphQL API.\n\nTo run the test script, you'll need to have Jest installed (npm install --save-dev jest) and execute the command npx jest in your project directory.\n\nFeel free to customize the test script further according to your specific requirements.\n\n## CLI Testing\n\nHere are a few CURL commands that you can use to test the GraphQL queries and mutations mentioned earlier:\n\nUser Registration Mutation:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"query\":\"mutation { createUser(input: { username: \\\"john_doe\\\", name: \\\"John Doe\\\", password: \\\"password\\\" }) { id username name } }\"}' http://your-api-endpoint\n```\n\nUser Login Mutation:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"query\":\"mutation { loginUser(input: { username: \\\"john_doe\\\", password: \\\"password\\\" }) { token } }\"}' http://your-api-endpoint\n```\n\nGet User Profile Query:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"query { userProfile(userId: \\\"user_id\\\") { id username name bio profilePicture followersCount followingCount postsCount followers { id username } following { id username } } }\"}' http://your-api-endpoint\n```\n\nFollow User Mutation:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"mutation { followUser(userId: \\\"user_id\\\") { id username } }\"}' http://your-api-endpoint\n```\n\nUnfollow User Mutation:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"mutation { unfollowUser(userId: \\\"user_id\\\") { id username } }\"}' http://your-api-endpoint\n```\n\nGet User's Followers Query:\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"query { userFollowers(userId: \\\"user_id\\\") { id username name profilePicture } }\"}' http://your-api-endpoint\n```\n\nGet User's Following Query:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"query { userFollowing(userId: \\\"user_id\\\") { id username name profilePicture } }\"}' http://your-api-endpoint\n```\n\nGet User's Feed Query:\n\n```shell\nCopy code\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"query { userFeed { id caption imageUrl likesCount commentsCount createdAt user { id username name profilePicture } } }\"}' http://your-api-endpoint\n```\n\nGet Post Query:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"query { post(postId: \\\"post_id\\\") { id caption imageUrl likesCount commentsCount createdAt user { id username name profilePicture } } }\"}' http://your-api-endpoint\n```\n  \nSearch Users Query:\n\n```shell\ncurl -X POST -H \"Content-Type: application/json\" -H \"Authorization: Bearer \u003ctoken\u003e\" -d '{\"query\":\"query { searchUsers(query: \\\"search_query\\\") { id username name profilePicture } }\"}' http://your-api-endpoint\n```\n\nMake sure to replace \u003ctoken\u003e, user_id, and post_id with the actual values you have obtained during authentication or from previous API responses.\n\nAlso, replace http://your-api-endpoint with the actual URL of your GraphQL API\n\n## Contributing\n\nContributions are welcome! If you find any issues or would like to add new features, feel free to open a pull request.\n\n## License\n\nThis project is licensed under the GPL-3.0 License.\n\nCopyright 2023, Max Base\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Finstagramgraphqlapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasemax%2Finstagramgraphqlapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasemax%2Finstagramgraphqlapi/lists"}