{"id":22125439,"url":"https://github.com/notadd/graphql-orm","last_synced_at":"2025-03-24T07:52:59.030Z","repository":{"id":42990089,"uuid":"204246664","full_name":"notadd/graphql-orm","owner":"notadd","description":"graphql-orm","archived":false,"fork":false,"pushed_at":"2024-05-26T16:41:57.000Z","size":2069,"stargazers_count":2,"open_issues_count":8,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-29T13:24:24.681Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/notadd.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-08-25T04:39:22.000Z","updated_at":"2021-09-23T23:10:46.000Z","dependencies_parsed_at":"2024-01-29T16:08:08.515Z","dependency_job_id":null,"html_url":"https://github.com/notadd/graphql-orm","commit_stats":null,"previous_names":[],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fgraphql-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fgraphql-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fgraphql-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notadd%2Fgraphql-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notadd","download_url":"https://codeload.github.com/notadd/graphql-orm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245232651,"owners_count":20581698,"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":[],"created_at":"2024-12-01T16:21:01.588Z","updated_at":"2025-03-24T07:52:59.007Z","avatar_url":"https://github.com/notadd.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"graphql + typeorm\n\n```ts\nimport { createConnection, SelectionSet, getRepository } from '../lib';\nimport { Post } from './entities/post';\nimport { User } from './entities/user';\nimport { graphql, GraphQLResolveInfo } from 'graphql';\nimport { makeExecutableSchema } from 'graphql-tools';\nasync function bootstrap() {\n    await createConnection({\n        type: 'postgres',\n        host: 'localhost',\n        port: 5432,\n        database: 'magnus',\n        username: 'default',\n        password: 'secret',\n        entities: [\n            User,\n            Post\n        ],\n        synchronize: true\n    });\n    const user = new User();\n    user.id = 2;\n    await user.save();\n    const post = new Post();\n    post.authorUid = 1;\n    post.likeUsers = [user];\n    Post.findAndCount()\n\n    const schema = makeExecutableSchema({\n        typeDefs: `\n        type Post{\n            id: Int\n            author: User\n        }\n        type User {\n            id: Int\n            get(id: Int): User\n            posts: [Post]\n        }\n        type UserList{\n            count: Int\n            list: [User]\n        }\n        type Query {\n        userList: UserList\n      }`,\n        resolvers: {\n            Query: {\n                userList: async (\n                    source: any,\n                    variables: any,\n                    context: any,\n                    info: GraphQLResolveInfo\n                ) =\u003e {\n                    const values = info.variableValues;\n                    return {\n                        count: async (\n                            source: any,\n                            args: any,\n                            info: GraphQLResolveInfo\n                        ) =\u003e {\n                            return 10;\n                        },\n                        list: async (\n                            source: any,\n                            args: any,\n                            info: GraphQLResolveInfo\n                        ) =\u003e {\n                            const sets = SelectionSet.fromGraphql(info);\n                            debugger;\n                            const obj = [];\n                            await Promise.all(sets.map(async set =\u003e {\n                                const where = {\n                                    select: set.selections as any,\n                                    relations: set.relations,\n                                    where: {},\n                                    order: {}\n                                }\n                                let res = await getRepository(User).find(where);\n                                let result = [];\n                                await Promise.all(set.actions.map(async action =\u003e {\n                                    await Promise.all(res \u0026\u0026 res.map(async li =\u003e {\n                                        li[action.name] = await li[action.name](action.args);\n                                        result.push(li);\n                                    }))\n                                }));\n                                if (result \u0026\u0026 result.length)\n                                    obj.push(...result)\n                            }));\n                            return obj;\n                        }\n                    }\n                }\n            }\n        }\n    })\n    return await graphql({\n        schema,\n        source: `query getList($id: Int){ \n        userList {\n            count,\n            list {\n                id,\n                get(id: $id){\n                    id\n                },\n                posts {\n                    id,\n                    author{\n                        id\n                    }\n                }\n            }\n        }}`,\n        rootValue: {},\n        contextValue: {},\n        variableValues: {\n            id: 1\n        },\n        operationName: ``\n    }).then(res =\u003e {\n        if (res.errors) {\n            throw new Error(`${res.errors.join(\"\\n\")}`);\n        }\n        return res.data;\n    });\n}\n\nbootstrap().then(res =\u003e {\n    debugger;\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotadd%2Fgraphql-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotadd%2Fgraphql-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotadd%2Fgraphql-orm/lists"}