├── Graphql using Apollo ├── express-graphql-apollo │ └── .gitkeep ├── nestjs-graphql-mongo-app │ ├── .env │ ├── .prettierrc │ ├── nest-cli.json │ ├── tsconfig.build.json │ ├── src │ │ ├── constants.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ ├── user │ │ │ ├── user.input.ts │ │ │ ├── user.providers.ts │ │ │ ├── user.module.ts │ │ │ ├── user.schema.ts │ │ │ ├── user.service.spec.ts │ │ │ └── user.resolver.spec.ts │ │ ├── database │ │ │ ├── database.module.ts │ │ │ └── database.providers.ts │ │ ├── app.controller.ts │ │ └── database.spec.ts │ ├── test │ │ └── jest-e2e.json │ ├── process.json │ ├── README.md │ ├── tsconfig.json │ ├── schema.gql │ └── .gitignore ├── express-graphql-apollo-knex │ └── .gitkeep ├── nestjs-graphql-code-first-#02 │ ├── .npmrc │ ├── env.example │ ├── env.test │ ├── ormconfig.ts │ ├── .gitlab-ci.yml │ ├── .eslintignore │ ├── commitlint.config.js │ ├── nest-cli.json │ ├── test │ │ ├── setEnvVars.js │ │ └── jest-e2e.json │ ├── .husky │ │ ├── pre-commit │ │ ├── commit-msg │ │ └── prepare-commit-msg │ ├── .env │ ├── docker-compose.yml │ ├── src │ │ ├── app.service.ts │ │ ├── main.ts │ │ ├── domain │ │ │ ├── project │ │ │ │ ├── dto │ │ │ │ │ ├── create-project.input.ts │ │ │ │ │ └── update-project.input.ts │ │ │ │ └── project.module.ts │ │ │ ├── category │ │ │ │ ├── dto │ │ │ │ │ ├── create-category.input.ts │ │ │ │ │ └── update-category.input.ts │ │ │ │ ├── category.module.ts │ │ │ │ └── category.service.spec.ts │ │ │ └── employee │ │ │ │ ├── dto │ │ │ │ ├── create-employee.input.ts │ │ │ │ └── update-employee.input.ts │ │ │ │ ├── employee.module.ts │ │ │ │ └── employee.service.spec.ts │ │ ├── app.controller.ts │ │ └── app.module.ts │ ├── .editorconfig │ ├── tsconfig.build.json │ ├── jest.config.js │ ├── docker-compose.override.yml │ ├── jest.config-e2e.js │ ├── tsconfig.json │ ├── Dockerfile │ ├── .gitignore │ └── .dockerignore ├── express-graphql-apollo-sequelize │ ├── .gitkeep │ ├── .gitignore │ ├── .sequelizerc │ ├── .dockerignore │ ├── Dockerfile │ └── src │ │ ├── resolvers │ │ ├── index.js │ │ └── authorization.js │ │ └── schema │ │ └── index.js ├── express-graphql-apollo-typeorm │ └── .gitkeep ├── nestjs-graphql-schema-first-#01 │ ├── .npmrc │ ├── env.test │ ├── .gitlab-ci.yml │ ├── env.example │ ├── ormconfig.ts │ ├── .eslintignore │ ├── commitlint.config.js │ ├── nest-cli.json │ ├── test │ │ ├── setEnvVars.js │ │ └── jest-e2e.json │ ├── .husky │ │ ├── pre-commit │ │ ├── commit-msg │ │ └── prepare-commit-msg │ ├── .env │ ├── docker-compose.yml │ ├── src │ │ ├── modules │ │ │ └── domain │ │ │ │ ├── pokemon │ │ │ │ ├── pokemon.dto.ts │ │ │ │ ├── pokemon.graphql │ │ │ │ └── pokemon.module.ts │ │ │ │ ├── league │ │ │ │ ├── league.graphql │ │ │ │ └── league.module.ts │ │ │ │ └── entity │ │ │ │ └── league.entity.ts │ │ ├── app.service.ts │ │ ├── main.ts │ │ ├── app.controller.ts │ │ └── app.module.ts │ ├── .editorconfig │ ├── tsconfig.build.json │ ├── jest.config.js │ ├── docker-compose.override.yml │ ├── jest.config-e2e.js │ ├── Dockerfile │ ├── .gitignore │ └── .dockerignore ├── express-graphql-apollo-mongo │ ├── src │ │ ├── resolvers │ │ │ ├── message.js │ │ │ ├── index.js │ │ │ └── authorization.js │ │ ├── schema │ │ │ ├── index.js │ │ │ └── message.js │ │ └── model │ │ │ ├── index.js │ │ │ └── message.js │ ├── .gitignore │ ├── .dockerignore │ ├── .babelrc │ ├── README.md │ └── docker-compose.yml ├── nest-graphql-prisma │ ├── .prettierrc │ ├── nest-cli.json │ ├── tsconfig.build.json │ ├── prisma │ │ ├── dev.db │ │ ├── migrations │ │ │ ├── migration_lock.toml │ │ │ └── 20210731111431_init │ │ │ │ └── migration.sql │ │ └── schema.prisma │ ├── src │ │ ├── app.service.ts │ │ ├── main.ts │ │ ├── generate-typings.ts │ │ ├── posts │ │ │ ├── posts.module.ts │ │ │ └── schema.graphql │ │ ├── app.controller.ts │ │ ├── app.module.ts │ │ ├── generate-typings.js │ │ └── prisma.service.ts │ ├── test │ │ └── jest-e2e.json │ ├── tsconfig.json │ ├── .env │ └── .gitignore ├── nestjs-graphql-example │ ├── .prettierrc │ ├── nest-cli.json │ ├── tsconfig.build.json │ ├── docker-compose.yml │ ├── src │ │ └── main.ts │ ├── tsconfig.json │ └── .gitignore ├── nestjs-graphql-prisma-app │ ├── src │ │ ├── auth │ │ │ ├── index.ts │ │ │ └── types │ │ │ │ ├── passport-user-fields.ts │ │ │ │ ├── session-user-fields.ts │ │ │ │ └── index.ts │ │ ├── user │ │ │ ├── types │ │ │ │ ├── index.ts │ │ │ │ └── user-profile-fields.ts │ │ │ ├── models │ │ │ │ └── user-login.input.ts │ │ │ └── testing │ │ │ │ └── index.ts │ │ ├── app_modules │ │ │ ├── prisma │ │ │ │ ├── testing │ │ │ │ │ └── index.ts │ │ │ │ └── index.ts │ │ │ ├── README.md │ │ │ ├── nestjs-passport-graphql-auth-guard │ │ │ │ └── index.ts │ │ │ └── nestjs-authorization-token │ │ │ │ └── index.ts │ │ ├── article │ │ │ ├── types │ │ │ │ ├── index.ts │ │ │ │ ├── article-author.ts │ │ │ │ └── article.ts │ │ │ ├── models │ │ │ │ └── article.model.ts │ │ │ └── author.guard.spec.ts │ │ ├── comment │ │ │ ├── models │ │ │ │ ├── comment.model.ts │ │ │ │ └── create-comment.input.ts │ │ │ └── comment.module.ts │ │ ├── tag │ │ │ ├── tag.model.ts │ │ │ ├── tag.module.ts │ │ │ └── tag.resolver.ts │ │ ├── api │ │ │ ├── fragments │ │ │ │ ├── index.ts │ │ │ │ ├── user.ts │ │ │ │ ├── comment.ts │ │ │ │ └── article.ts │ │ │ └── models │ │ │ │ ├── login-user.dto.ts │ │ │ │ ├── create-article-comment.dto.ts │ │ │ │ ├── create-article.dto.ts │ │ │ │ ├── create-user.dto.ts │ │ │ │ └── update-user.dto.ts │ │ └── @generated │ │ │ ├── tag │ │ │ ├── tag-count.output.ts │ │ │ ├── create-one-tag.args.ts │ │ │ ├── delete-many-tag.args.ts │ │ │ ├── tag-max-aggregate.input.ts │ │ │ ├── tag-max-aggregate.output.ts │ │ │ ├── tag-min-aggregate.input.ts │ │ │ ├── tag-min-aggregate.output.ts │ │ │ ├── tag-scalar-field.enum.ts │ │ │ ├── tag-where-unique.input.ts │ │ │ ├── tag-unchecked-update.input.ts │ │ │ ├── tag-unchecked-create.input.ts │ │ │ ├── delete-one-tag.args.ts │ │ │ ├── find-unique-tag.args.ts │ │ │ ├── tag-unchecked-update-many.input.ts │ │ │ ├── tag-update-many-mutation.input.ts │ │ │ ├── tag-create-without-articles.input.ts │ │ │ ├── tag-update-without-articles.input.ts │ │ │ ├── tag-order-by-relation-aggregate.input.ts │ │ │ ├── tag-unchecked-create-without-articles.input.ts │ │ │ ├── tag-unchecked-update-many-without-tags.input.ts │ │ │ ├── tag-unchecked-update-without-articles.input.ts │ │ │ ├── tag-order-by.input.ts │ │ │ ├── tag-count-aggregate.input.ts │ │ │ ├── tag-count-aggregate.output.ts │ │ │ ├── tag-max-order-by-aggregate.input.ts │ │ │ ├── tag-min-order-by-aggregate.input.ts │ │ │ ├── tag-count-order-by-aggregate.input.ts │ │ │ ├── update-one-tag.args.ts │ │ │ ├── tag-list-relation-filter.input.ts │ │ │ ├── update-many-tag.args.ts │ │ │ ├── tag-update.input.ts │ │ │ ├── tag-create.input.ts │ │ │ ├── tag-update-many-with-where-without-articles.input.ts │ │ │ ├── tag.model.ts │ │ │ ├── tag-create-or-connect-without-articles.input.ts │ │ │ └── tag-update-with-where-unique-without-articles.input.ts │ │ │ ├── prisma │ │ │ ├── affected-rows.output.ts │ │ │ └── sort-order.enum.ts │ │ │ ├── comment │ │ │ ├── comment-where-unique.input.ts │ │ │ ├── delete-many-comment.args.ts │ │ │ ├── create-one-comment.args.ts │ │ │ ├── delete-one-comment.args.ts │ │ │ ├── comment-order-by-relation-aggregate.input.ts │ │ │ ├── find-unique-comment.args.ts │ │ │ ├── comment-scalar-field.enum.ts │ │ │ ├── comment-update-many-mutation.input.ts │ │ │ ├── update-one-comment.args.ts │ │ │ ├── comment-list-relation-filter.input.ts │ │ │ └── update-many-comment.args.ts │ │ │ ├── article │ │ │ ├── article-avg-aggregate.input.ts │ │ │ ├── article-sum-aggregate.input.ts │ │ │ ├── article-sum-aggregate.output.ts │ │ │ ├── article-avg-aggregate.output.ts │ │ │ ├── article-where-unique.input.ts │ │ │ ├── delete-many-article.args.ts │ │ │ ├── create-one-article.args.ts │ │ │ ├── delete-one-article.args.ts │ │ │ ├── article-avg-order-by-aggregate.input.ts │ │ │ ├── article-order-by-relation-aggregate.input.ts │ │ │ ├── article-sum-order-by-aggregate.input.ts │ │ │ ├── find-unique-article.args.ts │ │ │ ├── article-count.output.ts │ │ │ ├── article-relation-filter.input.ts │ │ │ ├── update-one-article.args.ts │ │ │ ├── article-list-relation-filter.input.ts │ │ │ ├── update-many-article.args.ts │ │ │ ├── article-scalar-field.enum.ts │ │ │ └── article-create-or-connect-without-tags.input.ts │ │ │ └── user │ │ │ ├── delete-many-user.args.ts │ │ │ ├── create-one-user.args.ts │ │ │ ├── delete-one-user.args.ts │ │ │ ├── find-unique-user.args.ts │ │ │ ├── user-order-by-relation-aggregate.input.ts │ │ │ ├── user-where-unique.input.ts │ │ │ ├── user-relation-filter.input.ts │ │ │ ├── user-scalar-field.enum.ts │ │ │ ├── update-one-user.args.ts │ │ │ ├── update-many-user.args.ts │ │ │ ├── user-list-relation-filter.input.ts │ │ │ ├── user-count.output.ts │ │ │ ├── user-create-or-connect-without-articles.input.ts │ │ │ ├── user-create-or-connect-without-comments.input.ts │ │ │ ├── user-update-many-with-where-without-followers.input.ts │ │ │ ├── user-update-many-with-where-without-following.input.ts │ │ │ ├── user-create-or-connect-without-followers.input.ts │ │ │ └── user-create-or-connect-without-following.input.ts │ ├── .remarkrc.js │ ├── nest-cli.json │ ├── prisma │ │ ├── migrations │ │ │ └── migration_lock.toml │ │ └── data.db │ ├── logo.png │ ├── .dockerignore │ ├── tsconfig.build.json │ ├── .editorconfig │ ├── .prettierrc.js │ └── .releaserc.js ├── nestjs-graphql-typeorm │ ├── .prettierrc │ ├── nest-cli.json │ ├── src │ │ ├── modules │ │ │ ├── api │ │ │ │ ├── user │ │ │ │ │ ├── user.service.ts │ │ │ │ │ ├── user.controller.ts │ │ │ │ │ └── user.module.ts │ │ │ │ ├── league │ │ │ │ │ ├── league.graphql │ │ │ │ │ └── league.module.ts │ │ │ │ └── pokemon │ │ │ │ │ ├── pokemon.module.ts │ │ │ │ │ └── pokemon.graphql │ │ │ ├── ressources │ │ │ │ └── pokemon.ressource.ts │ │ │ ├── config │ │ │ │ ├── config.module.ts │ │ │ │ └── config.service.ts │ │ │ └── entity │ │ │ │ └── league.entity.ts │ │ └── main.ts │ ├── tsconfig.build.json │ ├── test │ │ └── jest-e2e.json │ ├── .env.example │ ├── schema.gpl │ ├── tsconfig.json │ ├── tslint.json │ └── .gitignore ├── nest-graphql-code-first-mongoose-#03 │ ├── .prettierrc │ ├── nodemon.json │ ├── nest-cli.json │ ├── tsconfig.build.json │ ├── src │ │ ├── app.service.ts │ │ ├── items │ │ │ ├── items.schema.ts │ │ │ ├── interfaces │ │ │ │ └── item.interface.ts │ │ │ ├── input-items.input.ts │ │ │ ├── dto │ │ │ │ └── create-item.dto.ts │ │ │ └── items.module.ts │ │ ├── app.controller.ts │ │ └── main.ts │ ├── nodemon-debug.json │ ├── docker-compose.yaml │ ├── test │ │ └── jest-e2e.json │ ├── tsconfig.json │ ├── tslint.json │ └── .gitignore └── nestjs-graphql-prisma-schema-first-#04 │ ├── .prettierrc │ ├── nest-cli.json │ ├── docker-compose.yml │ ├── tsconfig.build.json │ ├── prisma │ └── migrations │ │ ├── migration_lock.toml │ │ └── 20220421085319_ │ │ └── migration.sql │ ├── src │ ├── app.service.ts │ ├── main.ts │ ├── generate-typings.ts │ ├── posts │ │ └── posts.module.ts │ ├── app.controller.ts │ ├── app.module.ts │ ├── generate-typings.js │ └── prisma.service.ts │ ├── test │ └── jest-e2e.json │ ├── docker-compose.override.yml │ ├── tsconfig.json │ ├── Dockerfile │ ├── .env │ └── .gitignore └── Grapql using Yoga Gql ├── express-graphql-yoga ├── .gitkeep ├── advance-series │ ├── src │ │ ├── seed.js │ │ ├── api │ │ │ ├── search │ │ │ │ ├── search.graphql │ │ │ │ └── index.js │ │ │ ├── task │ │ │ │ └── index.js │ │ │ ├── project │ │ │ │ ├── index.js │ │ │ │ ├── project.model.js │ │ │ │ └── project.graphql │ │ │ ├── github.js │ │ │ └── index.js │ │ ├── db.js │ │ ├── utils │ │ │ └── gqlLoader.js │ │ └── server.js │ ├── nodemon.json │ └── tests │ │ └── run.js ├── graphql-starter-series │ ├── setup-01 │ │ ├── src │ │ │ └── index.js │ │ ├── .babelrc │ │ └── package.json │ ├── custom-types-02 │ │ ├── .babelrc │ │ └── package.json │ ├── graphql-mutations-05 │ │ ├── .babelrc │ │ └── package.json │ ├── relational-basics-03 │ │ ├── .babelrc │ │ └── package.json │ ├── graphql-apis-comments-04 │ │ ├── .babelrc │ │ └── package.json │ ├── graphql-blog-apis-08 │ │ ├── .babelrc │ │ └── src │ │ │ └── resolvers │ │ │ ├── Comment.js │ │ │ ├── Post.js │ │ │ └── User.js │ ├── graphql-blog-posts-09 │ │ ├── .babelrc │ │ └── src │ │ │ └── resolvers │ │ │ ├── Comment.js │ │ │ ├── Post.js │ │ │ └── User.js │ ├── graphql-folder-restructuring-05 │ │ ├── .babelrc │ │ └── src │ │ │ └── resolvers │ │ │ ├── Comment.js │ │ │ ├── Post.js │ │ │ └── User.js │ ├── graphql-queries-07 │ │ ├── .babelrc │ │ └── src │ │ │ └── resolvers │ │ │ ├── Comment.js │ │ │ ├── Post.js │ │ │ └── User.js │ ├── project-structure-06 │ │ └── .babelrc │ └── graphql-subscription-10 │ │ ├── .babelrc │ │ └── src │ │ └── resolvers │ │ ├── Comment.js │ │ ├── Post.js │ │ └── User.js ├── graphql-client │ ├── public │ │ ├── robots.txt │ │ ├── favicon.ico │ │ ├── logo192.png │ │ └── logo512.png │ └── src │ │ ├── container │ │ └── app.module.css │ │ ├── graphql │ │ ├── index.js │ │ ├── queries.js │ │ ├── subscriptions.js │ │ └── mutations.js │ │ ├── setupTests.js │ │ └── index.css ├── hello-world │ ├── .babelrc │ └── src │ │ └── resolvers │ │ ├── Comment.js │ │ ├── Post.js │ │ ├── User.js │ │ └── Mutation.js ├── graphql-mongodb │ ├── .babelrc │ ├── docker-compose.yml │ ├── Dockerfile │ ├── .gitignore │ ├── database │ │ ├── config │ │ │ └── index.js │ │ └── models │ │ │ └── Comment.js │ ├── .env.example │ └── graphql │ │ └── index.js ├── graphql-server │ ├── .babelrc │ └── src │ │ └── resolvers │ │ ├── Comment.js │ │ ├── Post.js │ │ └── User.js └── pokemon-graphql │ └── .babelrc ├── express-graphql-yoga-prisma ├── .gitkeep ├── src │ ├── resolvers │ │ ├── Post.js │ │ ├── Comment.js │ │ └── index.js │ └── utils │ │ ├── generateToken.js │ │ ├── hashPassword.js │ │ └── getUserId.js ├── prisma-review-website │ ├── prisma.yml │ └── datamodel.graphql └── prisma │ └── prisma.yml ├── graphql-yoga-with-typeorm ├── .graphqlconfig ├── src │ ├── types │ │ └── resolvers.d.ts │ ├── api │ │ └── User │ │ │ ├── GetMyProfile │ │ │ └── GetMyProfile.graphql │ │ │ ├── shared │ │ │ └── User.graphql │ │ │ ├── EmailSignIn │ │ │ └── EmailSignIn.graphql │ │ │ └── EmailSignUp │ │ │ └── EmailSignUp.graphql │ ├── utils │ │ ├── createJWT.ts │ │ ├── privateResolver.ts │ │ └── decodeJWT.ts │ └── ormConfig.ts └── tslint.json ├── express-graphql-prisma ├── .gitignore ├── src │ ├── resolvers │ │ ├── types │ │ │ └── Context.ts │ │ ├── Subscription.ts │ │ ├── City.ts │ │ ├── MutationResult.ts │ │ ├── Picture.ts │ │ ├── PlaceViews.ts │ │ ├── CityPreviousValues.ts │ │ ├── AuthPayload.ts │ │ ├── Message.ts │ │ ├── Location.ts │ │ └── ExperienceCategory.ts │ ├── index.ts │ └── utils.ts ├── tsconfig.json └── renovate.json └── express-graphql-mongodb ├── .babelrc ├── docker-compose.yml ├── Dockerfile ├── .gitignore ├── database ├── config │ └── index.js └── models │ └── Comment.js ├── .env.example └── graphql └── index.js /Graphql using Apollo/express-graphql-apollo/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/.env: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-knex/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.npmrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-typeorm/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/env.example: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/env.test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/ormconfig.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.npmrc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/env.test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/env.example: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/ormconfig.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/seed.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/src/resolvers/message.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-example/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/auth/index.ts: -------------------------------------------------------------------------------- 1 | export { PassportUserFields } from './types'; 2 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/setup-01/src/index.js: -------------------------------------------------------------------------------- 1 | console.log('Hello GraphQL') -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_store 3 | .env 4 | node_modules 5 | 6 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_store 3 | .env 4 | node_modules 5 | 6 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/.remarkrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [['toc'], ['license']], 3 | }; 4 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/user/types/index.ts: -------------------------------------------------------------------------------- 1 | export { UserProfileFields } from './user-profile-fields'; 2 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | const Post = { 2 | 3 | } 4 | 5 | export { Post as default } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.eslintignore: -------------------------------------------------------------------------------- 1 | src/migrations/*.ts 2 | node_modules 3 | coverage 4 | .vscode 5 | dist -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-example/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "trailingComma": "all" 4 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.eslintignore: -------------------------------------------------------------------------------- 1 | src/migrations/*.ts 2 | node_modules 3 | coverage 4 | .vscode 5 | dist -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: ["@commitlint/config-conventional"] }; 2 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | const Comment = { 2 | 3 | } 4 | 5 | export { Comment as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/setup-01/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ] 5 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/test/setEnvVars.js: -------------------------------------------------------------------------------- 1 | const dotenv = require('dotenv'); 2 | dotenv.config({ path: './env.test' }); -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | provider = "sqlite" -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/app_modules/prisma/testing/index.ts: -------------------------------------------------------------------------------- 1 | export { DummyRepository } from './dummy.repository'; 2 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: ["@commitlint/config-conventional"] }; 2 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/test/setEnvVars.js: -------------------------------------------------------------------------------- 1 | const dotenv = require('dotenv'); 2 | dotenv.config({ path: './env.test' }); -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/custom-types-02/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ] 5 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | npm run lint && npm run prettier -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": "@nestjs/schematics", 3 | "sourceRoot": "src" 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | npm run lint && npm run prettier -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-mutations-05/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ] 5 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/relational-basics-03/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ] 5 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/.graphqlconfig: -------------------------------------------------------------------------------- 1 | { 2 | "schemaPath": "src/schema.graphql", 3 | "includes": ["src/**/*.graphql"] 4 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["dist"], 3 | "ext": "js", 4 | "exec": "node dist/main" 5 | } 6 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-apis-comments-04/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ] 5 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.env: -------------------------------------------------------------------------------- 1 | NODE_ENV=local 2 | PORT=3000 3 | DATABASE_URL=postgres://api:development_pass@localhost:5434/example-api -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.env: -------------------------------------------------------------------------------- 1 | NODE_ENV=local 2 | PORT=3000 3 | DATABASE_URL=postgres://api:development_pass@localhost:5434/example-api -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "ts", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/prisma-review-website/prisma.yml: -------------------------------------------------------------------------------- 1 | endpoint: http://localhost:4466/reviews/default 2 | datamodel: datamodel.graphql -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/article/types/index.ts: -------------------------------------------------------------------------------- 1 | export { Article } from './article'; 2 | export { ArticleAuthor } from './article-author'; 3 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/.gitignore: -------------------------------------------------------------------------------- 1 | .env* 2 | dist 3 | package-lock.json 4 | node_modules 5 | .idea 6 | *.log 7 | .graphcoolrc 8 | **/.DS_Store 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/prisma/prisma.yml: -------------------------------------------------------------------------------- 1 | endpoint: http://localhost:4466 2 | datamodel: datamodel.graphql 3 | secret: thisismysupersecrettext -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.husky/commit-msg: -------------------------------------------------------------------------------- 1 | # commit-msg 2 | #!/bin/sh 3 | . "$(dirname "$0")/_/husky.sh" 4 | npx --no-install commitlint --edit $1 -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.6" 2 | services: 3 | postgres: 4 | image: postgres 5 | restart: unless-stopped -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.husky/commit-msg: -------------------------------------------------------------------------------- 1 | # commit-msg 2 | #!/bin/sh 3 | . "$(dirname "$0")/_/husky.sh" 4 | npx --no-install commitlint --edit $1 -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.6" 2 | services: 3 | postgres: 4 | image: postgres 5 | restart: unless-stopped -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/nest-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "language": "ts", 3 | "collection": "@nestjs/schematics", 4 | "sourceRoot": "src" 5 | } 6 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/prisma/dev.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkssharma/nodejs-graphql-world/HEAD/Graphql using Apollo/nest-graphql-prisma/prisma/dev.db -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-example/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkssharma/nodejs-graphql-world/HEAD/Graphql using Apollo/nestjs-graphql-prisma-app/logo.png -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/article/models/article.model.ts: -------------------------------------------------------------------------------- 1 | import { Article } from '@generated/article/article.model'; 2 | 3 | export { Article }; 4 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/auth/types/passport-user-fields.ts: -------------------------------------------------------------------------------- 1 | export interface PassportUserFields { 2 | id: string; 3 | email: string; 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/auth/types/session-user-fields.ts: -------------------------------------------------------------------------------- 1 | export interface SessionTokenFields { 2 | sub: string; 3 | email: string; 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/comment/models/comment.model.ts: -------------------------------------------------------------------------------- 1 | import { Comment } from '@generated/comment/comment.model'; 2 | 3 | export { Comment }; 4 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/.sequelizerc: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | 'config': path.resolve('config', 'config.js') 5 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.6" 2 | services: 3 | postgres: 4 | image: postgres 5 | restart: unless-stopped -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/modules/domain/pokemon/pokemon.dto.ts: -------------------------------------------------------------------------------- 1 | 2 | export class CreatePokemonDto { 3 | name: string; 4 | type: string; 5 | } 6 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mongodb: 4 | image: 'mongo:latest' 5 | ports: 6 | - 27017:27017 7 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/hello-world/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/prisma/data.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkssharma/nodejs-graphql-world/HEAD/Graphql using Apollo/nestjs-graphql-prisma-app/prisma/data.db -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/tag/tag.model.ts: -------------------------------------------------------------------------------- 1 | import { Field, ID, ObjectType } from '@nestjs/graphql'; 2 | 3 | export { Tag } from '@generated/tag/tag.model'; 4 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/api/user/user.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class UserService {} 5 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-server/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/pokemon-graphql/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/.dockerignore: -------------------------------------------------------------------------------- 1 | * 2 | !/package.json 3 | !/package-lock.json 4 | !/Taskfile 5 | !/tsconfig.json 6 | !/tsconfig.build.json 7 | !/src 8 | !/prisma 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mongodb: 4 | image: 'mongo:latest' 5 | ports: 6 | - 27017:27017 7 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/ressources/pokemon.ressource.ts: -------------------------------------------------------------------------------- 1 | 2 | export class CreatePokemonDto { 3 | name: string; 4 | type: string; 5 | pokedex: number; 6 | } 7 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/auth/types/index.ts: -------------------------------------------------------------------------------- 1 | export { PassportUserFields } from './passport-user-fields'; 2 | export { SessionTokenFields } from './session-user-fields'; 3 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "./src/graphql.schema.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "sqlite" -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/constants.ts: -------------------------------------------------------------------------------- 1 | // src/constants.ts 2 | export const MONO_DB_CONNECTION_STRING = 3 | process.env.MONO_DB_CONNECTION_STRING || 'mongodb://localhost/nest'; 4 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/fragments/index.ts: -------------------------------------------------------------------------------- 1 | export { articleFields } from './article'; 2 | export { commentFields } from './comment'; 3 | export { userFields } from './user'; 4 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/types/Context.ts: -------------------------------------------------------------------------------- 1 | import { Prisma } from '../../generated/prisma-client' 2 | 3 | export interface Context { 4 | db: Prisma 5 | request: any 6 | } 7 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/models/login-user.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User submits when login. 3 | */ 4 | export class LoginUserDto { 5 | email: string; 6 | password: string; 7 | } 8 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "sourceMap": true, 4 | "outDir": "dist", 5 | "strict": false, 6 | "lib": ["esnext", "dom"] 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "verbose": true, 3 | "watch": ["src/*", "index.js", "config.js"], 4 | "runOnChangeOnly": true, 5 | "ext": "js,json,graphql" 6 | } 7 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkssharma/nodejs-graphql-world/HEAD/Grapql using Yoga Gql/express-graphql-yoga/graphql-client/public/favicon.ico -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkssharma/nodejs-graphql-world/HEAD/Grapql using Yoga Gql/express-graphql-yoga/graphql-client/public/logo192.png -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tkssharma/nodejs-graphql-world/HEAD/Grapql using Yoga Gql/express-graphql-yoga/graphql-client/public/logo512.png -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/article/types/article-author.ts: -------------------------------------------------------------------------------- 1 | export interface ArticleAuthor { 2 | username: string; 3 | bio: string; 4 | image: string; 5 | following: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/search/search.graphql: -------------------------------------------------------------------------------- 1 | union SearchResult = Project | DevTask | DesignTask 2 | 3 | extend type Query { 4 | search(name: String!): [SearchResult]! 5 | } 6 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | Dockerfile* 4 | docker-compose* 5 | .dockerignore 6 | .git 7 | .gitignore 8 | README.md 9 | LICENSE 10 | .vscode 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.husky/prepare-commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | if [ "$NO_VERIFY" ]; then exit 0; fi 5 | exec < /dev/tty && node_modules/.bin/cz --hook || true -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.husky/prepare-commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | if [ "$NO_VERIFY" ]; then exit 0; fi 5 | exec < /dev/tty && node_modules/.bin/cz --hook || true -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:10 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY ./package*.json ./ 6 | 7 | RUN npm install 8 | 9 | COPY ./ ./ 10 | 11 | CMD [ "npm", "run", "server" ] -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-apis-08/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-posts-09/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-folder-restructuring-05/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-queries-07/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/project-structure-06/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/.dockerignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | Dockerfile* 4 | docker-compose* 5 | .dockerignore 6 | .git 7 | .gitignore 8 | README.md 9 | LICENSE 10 | .vscode 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/models/create-article-comment.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Shape of create article data transfer object. 3 | */ 4 | export class CreateArticleCommentDto { 5 | body: string; 6 | } 7 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/models/create-article.dto.ts: -------------------------------------------------------------------------------- 1 | export interface CreateArticleDto { 2 | title: string; 3 | description: string; 4 | body: string; 5 | tagList: string[]; 6 | } 7 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/user/types/user-profile-fields.ts: -------------------------------------------------------------------------------- 1 | export interface UserProfileFields { 2 | username: string; 3 | bio: string; 4 | image: string; 5 | following: boolean; 6 | } 7 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (i.e. Git) 3 | provider = "postgresql" -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/search/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | resolvers: require('./search.resolvers'), 3 | typeDefs: require('../../utils/gqlLoader')('search/search.graphql'), 4 | } 5 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-subscription-10/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "env" 4 | ], 5 | "plugins": [ 6 | "transform-object-rest-spread" 7 | ] 8 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/app_modules/README.md: -------------------------------------------------------------------------------- 1 | # App Modules 2 | 3 | Shared, common, helpers, etc. which can be imported from any part of application. 4 | But app modules cannot import other app modules. 5 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | .env 6 | 7 | # IDEs and editors 8 | /.idea 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/src/container/app.module.css: -------------------------------------------------------------------------------- 1 | .title { 2 | text-align: center; 3 | margin: 50px; 4 | color: rgb(37, 37, 37); 5 | } 6 | 7 | .form { 8 | padding: 50px; 9 | } 10 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/src/graphql/index.js: -------------------------------------------------------------------------------- 1 | export { POSTS_QUERY } from './queries'; 2 | export { CREATE_POST_MUTATION } from './mutations'; 3 | export { POSTS_SUBSCRIPTION } from './subscriptions'; 4 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": false 5 | }, 6 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:10 2 | 3 | WORKDIR /usr/src/app 4 | 5 | COPY ./package*.json ./ 6 | 7 | RUN npm install 8 | 9 | COPY ./ ./ 10 | 11 | CMD [ "npm", "run", "server" ] -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "@babel/preset-env", { 5 | "targets": { 6 | "node": "current" 7 | } 8 | } 9 | ] 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/app_modules/nestjs-passport-graphql-auth-guard/index.ts: -------------------------------------------------------------------------------- 1 | export { GraphqlAuthGuard } from './graphql-auth.guard'; 2 | export { OptionalGraphqlAuthGuard } from './optional-graphql-auth.guard'; 3 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/hello-world/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | const Comment = { 2 | author(parent, args, { DB }, info) { 3 | return DB.users.find((i) => i.id === parent.author); 4 | } 5 | } 6 | 7 | export default Comment; -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/items/items.schema.ts: -------------------------------------------------------------------------------- 1 | import * as mongoose from 'mongoose'; 2 | 3 | export const ItemSchema = new mongoose.Schema({ 4 | title: String, 5 | price: Number, 6 | description: String 7 | }) -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | getHello(): string { 6 | return 'Hello World!'; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | .env 6 | 7 | # IDEs and editors 8 | /.idea 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/db.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | 3 | const connectToDB = (url = 'mongodb://localhost/done') => { 4 | return mongoose.connect(url) 5 | } 6 | 7 | module.exports = connectToDB 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/nodemon-debug.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": "ts", 4 | "ignore": ["src/**/*.spec.ts"], 5 | "exec": "node --inspect-brk -r ts-node/register -r tsconfig-paths/register src/main.ts" 6 | } 7 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/models/create-user.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Shape of create user data transfer object. 3 | */ 4 | export class CreateUserDto { 5 | email: string; 6 | username: string; 7 | password: string; 8 | } 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/task/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | resolvers: require('./task.resolvers'), 3 | typeDefs: require('../../utils/gqlLoader')('task/task.graphql'), 4 | model: require('./task.model') 5 | } 6 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/database/config/index.js: -------------------------------------------------------------------------------- 1 | 2 | import User from '../models/User'; 3 | import Post from '../models/Post'; 4 | import Comment from '../models/Comment'; 5 | export const models = { 6 | User, 7 | Post, 8 | Comment 9 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | "docker:disable", 5 | ":skipStatusChecks" 6 | ], 7 | "automerge": true, 8 | "major": { 9 | "automerge": false 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/types/resolvers.d.ts: -------------------------------------------------------------------------------- 1 | export type Resolver = (parent: any, args: any, context: any, info: any) => any; 2 | 3 | export interface Resolvers { 4 | [key: string]: { 5 | [key: string]: Resolver; 6 | }; 7 | } 8 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/api/User/GetMyProfile/GetMyProfile.graphql: -------------------------------------------------------------------------------- 1 | type GetMyProfileResponse { 2 | ok: Boolean! 3 | error: String 4 | profile: User 5 | } 6 | 7 | type Query { 8 | GetMyProfile: GetMyProfileResponse! 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-count.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagCount { 5 | @Field(() => Int, { nullable: false }) 6 | articles!: number; 7 | } 8 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/project/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | resolvers: require('./project.resolvers'), 3 | typeDefs: require('../../utils/gqlLoader')('project/project.graphql'), 4 | model: require('./project.model') 5 | } 6 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/database/config/index.js: -------------------------------------------------------------------------------- 1 | 2 | import User from '../models/User'; 3 | import Post from '../models/Post'; 4 | import Comment from '../models/Comment'; 5 | export const models = { 6 | User, 7 | Post, 8 | Comment 9 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | services: 3 | mongodb: 4 | image: mongo 5 | ports: 6 | - 27017:27017 7 | volumes: 8 | - mongodb_data:/data/db 9 | 10 | volumes: 11 | mongodb_data: -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/fragments/user.ts: -------------------------------------------------------------------------------- 1 | export const userFields = /* GraphQL */ ` 2 | fragment userFields on User { 3 | userId 4 | username: name 5 | email 6 | bio 7 | image 8 | } 9 | `; 10 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/.env.example: -------------------------------------------------------------------------------- 1 | ################################### 2 | Set this file and copy it into .env 3 | ################################### 4 | mongoURI=mongodb://:@ds155653.mlab.com:55653/ 5 | secretOrKey=secret -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/src/utils/generateToken.js: -------------------------------------------------------------------------------- 1 | import jwt from 'jsonwebtoken' 2 | 3 | const generateToken = (userId) => { 4 | return jwt.sign({ userId }, 'thisisasecret', { expiresIn: '7 days' }) 5 | } 6 | 7 | export { generateToken as default } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/prisma/affected-rows.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class AffectedRows { 5 | @Field(() => Int, { nullable: false }) 6 | count!: number; 7 | } 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/items/interfaces/item.interface.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | import { Document } from 'mongoose'; 4 | 5 | export interface Item extends Document { 6 | readonly title: string; 7 | readonly price: number; 8 | readonly description: string; 9 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/.env.example: -------------------------------------------------------------------------------- 1 | ################################### 2 | Set this file and copy it into .env 3 | ################################### 4 | mongoURI=mongodb://:@ds155653.mlab.com:55653/ 5 | secretOrKey=secret -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/api/User/shared/User.graphql: -------------------------------------------------------------------------------- 1 | type User { 2 | id: Int! 3 | email: String! 4 | password: String! 5 | firstName: String! 6 | lastName: String! 7 | fullName: String! 8 | createdAt: String! 9 | updatedAt: String 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/comment-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | } 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/models/update-user.dto.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * User submits when update. 3 | */ 4 | export class UpdateUserDto { 5 | email?: string; 6 | username?: string; 7 | password?: string; 8 | image?: string; 9 | bio?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/src/resolvers/index.js: -------------------------------------------------------------------------------- 1 | import {GraphQLDateTime} from 'graphql-iso-date' 2 | 3 | const customScalarResolver = { 4 | Date: GraphQLDateTime, 5 | }; 6 | 7 | import userResolver from './user'; 8 | 9 | export default [customScalarResolver, userResolver] -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-example/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | database: 4 | image: postgres:alpine 5 | ports: 6 | - 5432:5432 7 | environment: 8 | POSTGRES_USER: example 9 | POSTGRES_PASSWORD: example 10 | POSTGRES_DB: example -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/test/jest-e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "moduleFileExtensions": ["js", "json", "ts"], 3 | "rootDir": ".", 4 | "testEnvironment": "node", 5 | "testRegex": ".e2e-spec.ts$", 6 | "transform": { 7 | "^.+\\.(t|j)s$": "ts-jest" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/.env.example: -------------------------------------------------------------------------------- 1 | # APP 2 | APP_ENV=dev 3 | APP_URL=http://127.0.0.1 4 | APP_PORT=3000 5 | 6 | # DATABASE 7 | DB_TYPE=mysql 8 | DB_HOST=127.0.0.1 9 | DB_PORT=3306 10 | DB_USERNAME=root 11 | DB_PASSWORD= 12 | DB_DATABASE=graphql-test 13 | DB_SYNC=true 14 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/api/User/EmailSignIn/EmailSignIn.graphql: -------------------------------------------------------------------------------- 1 | type EmailSignInResponse { 2 | ok: Boolean! 3 | error: String 4 | token: String 5 | } 6 | 7 | type Mutation { 8 | EmailSignIn(email: String!, password: String!): EmailSignInResponse! 9 | } 10 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/utils/createJWT.ts: -------------------------------------------------------------------------------- 1 | import jwt from "jsonwebtoken"; 2 | 3 | const createJWT = (id: number): string => { 4 | const token = jwt.sign({ id }, process.env.JWT_SECRET || ""); 5 | 6 | return token; 7 | }; 8 | 9 | export default createJWT; 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-example/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | 9 | bootstrap(); 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-avg-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleAvgAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | favoritesCount?: true; 7 | } 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-sum-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleSumAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | favoritesCount?: true; 7 | } 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-sum-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleSumAggregate { 5 | @Field(() => Int, { nullable: true }) 6 | favoritesCount?: number; 7 | } 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/prisma/sort-order.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum SortOrder { 4 | asc = 'asc', 5 | desc = 'desc', 6 | } 7 | 8 | registerEnumType(SortOrder, { name: 'SortOrder', description: undefined }); 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | 4 | async function bootstrap() { 5 | const app = await NestFactory.create(AppModule); 6 | await app.listen(3000); 7 | } 8 | bootstrap(); 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-avg-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Float, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleAvgAggregate { 5 | @Field(() => Float, { nullable: true }) 6 | favoritesCount?: number; 7 | } 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/project/dto/create-project.input.ts: -------------------------------------------------------------------------------- 1 | import { InputType, Int, Field } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CreateProjectInput { 5 | @Field() 6 | name: string; 7 | 8 | 9 | @Field(() => Int) 10 | code: number; 11 | } -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/README.md: -------------------------------------------------------------------------------- 1 | # Graphql-fullstack-tutorials 2 | 3 | - Apollo graphql with Mongoose MongoDB 4 | - Apollo Grapqhl with Mysql Sequelize 5 | 6 | https://www.youtube.com/watch?v=d8g2ESwn3XA&list=PLIGDNOJWiL19Nylkg_DJtKpBB-t6tVuRg 7 | 8 | 🚀🚀🚀 React Training Sessions 🚀🚀🚀 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/category/dto/create-category.input.ts: -------------------------------------------------------------------------------- 1 | import { InputType, Int, Field } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CreateCategoryInput { 5 | @Field(() => Int, { description: 'Example field (placeholder)' }) 6 | exampleField: number; 7 | } 8 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:carbon 2 | # Create app directory 3 | WORKDIR /usr/src/app 4 | # Bundle app source 5 | COPY . . 6 | # npm install 7 | RUN npm install 8 | # Run npm install --global grpc --unsafe-perm 9 | EXPOSE 3000 9204 10 | CMD [ "npm", "run", "start" ] 11 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/src/graphql/queries.js: -------------------------------------------------------------------------------- 1 | import { gql } from '@apollo/client'; 2 | 3 | export const POSTS_QUERY = gql` 4 | query { 5 | posts { 6 | title 7 | body 8 | author { 9 | name 10 | } 11 | published 12 | } 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/user/user.input.ts: -------------------------------------------------------------------------------- 1 | // src/user/user.input.ts 2 | import { Field, InputType } from '@nestjs/graphql'; 3 | 4 | @InputType() 5 | export class CreateUserInput { 6 | @Field() 7 | name: string; 8 | 9 | @Field() 10 | email: string; 11 | 12 | @Field() 13 | age: number; 14 | } 15 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/Subscription.ts: -------------------------------------------------------------------------------- 1 | import { SubscriptionResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface SubscriptionParent {} 5 | 6 | export const Subscription: SubscriptionResolvers.Type = { 7 | city: parent => null, 8 | } 9 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/utils/gqlLoader.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const path = require('path') 3 | 4 | const loadGQLFile = (type) => { 5 | const filePath = path.join(__dirname, '../api', type) 6 | return fs.readFileSync(filePath, 'utf-8') 7 | } 8 | 9 | module.exports = loadGQLFile 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/process.json: -------------------------------------------------------------------------------- 1 | { 2 | "apps": [ 3 | { 4 | "name": "server", 5 | "script": "dist/main.js", 6 | "watch": false, 7 | "instances": "max", 8 | "exec_mode": "cluster", 9 | "env": { 10 | "NODE_ENV": "production" 11 | } 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/api/user/user.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get, Req, Res } from '@nestjs/common'; 2 | 3 | @Controller('users') 4 | export class UserController { 5 | 6 | @Get() 7 | async index(@Req() req, @Res() res) { 8 | res.send({ 9 | hello: 'world', 10 | }); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | insert_final_newline = false 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/create-one-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagCreateInput } from './tag-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneTagArgs { 7 | @Field(() => TagCreateInput, { nullable: false }) 8 | data!: TagCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/delete-many-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagWhereInput } from './tag-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyTagArgs { 7 | @Field(() => TagWhereInput, { nullable: true }) 8 | where?: TagWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | indent_size = 2 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | insert_final_newline = false 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/items/input-items.input.ts: -------------------------------------------------------------------------------- 1 | import {InputType, Field, Int} from '@nestjs/graphql' 2 | 3 | @InputType() 4 | export class ItemInput { 5 | @Field() 6 | readonly title: string 7 | 8 | @Field(() => Int) 9 | readonly price: number 10 | 11 | @Field() 12 | readonly description: string 13 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/delete-many-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserWhereInput } from './user-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyUserArgs { 7 | @Field(() => UserWhereInput, { nullable: true }) 8 | where?: UserWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/api/user/user.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { UserController } from './user.controller'; 3 | import { UserService } from './user.service'; 4 | 5 | @Module({ 6 | controllers: [UserController], 7 | providers: [UserService], 8 | }) 9 | export class UserModule { 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/database/database.module.ts: -------------------------------------------------------------------------------- 1 | // src/database/database.module.ts 2 | import { Module } from '@nestjs/common'; 3 | import { databaseProviders } from './database.providers'; 4 | 5 | @Module({ 6 | providers: [...databaseProviders], 7 | exports: [...databaseProviders], 8 | }) 9 | export class DatabaseModule {} 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-max-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagMaxAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | tagId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | name?: true; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-max-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagMaxAggregate { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-min-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagMinAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | tagId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | name?: true; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-min-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagMinAggregate { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum TagScalarFieldEnum { 4 | tagId = 'tagId', 5 | name = 'name', 6 | } 7 | 8 | registerEnumType(TagScalarFieldEnum, { 9 | name: 'TagScalarFieldEnum', 10 | description: undefined, 11 | }); 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/create-one-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserCreateInput } from './user-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneUserArgs { 7 | @Field(() => UserCreateInput, { nullable: false }) 8 | data!: UserCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/src/utils/hashPassword.js: -------------------------------------------------------------------------------- 1 | import bcrypt from 'bcryptjs' 2 | 3 | const hashPassword = (password) => { 4 | if (password.length < 8) { 5 | throw new Error('Password must be 8 characters or longer.') 6 | } 7 | 8 | return bcrypt.hash(password, 10) 9 | } 10 | 11 | export { hashPassword as default } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/prisma/migrations/20210731111431_init/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "Post" ( 3 | "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 4 | "title" TEXT NOT NULL, 5 | "content" TEXT NOT NULL, 6 | "published" BOOLEAN NOT NULL DEFAULT false, 7 | "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP 8 | ); 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/generate-typings.ts: -------------------------------------------------------------------------------- 1 | import { GraphQLDefinitionsFactory } from '@nestjs/graphql'; 2 | import { join } from 'path'; 3 | const definitionsFactory = new GraphQLDefinitionsFactory(); 4 | definitionsFactory.generate({ 5 | typePaths: ['./src/**/*.graphql'], 6 | path: join(process.cwd(), 'src/graphql.ts'), 7 | outputAs: 'class', 8 | }); -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-unchecked-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedUpdateInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/api/User/EmailSignUp/EmailSignUp.graphql: -------------------------------------------------------------------------------- 1 | type EmailSignUpResponse { 2 | ok: Boolean! 3 | error: String 4 | user: User 5 | } 6 | 7 | type Mutation { 8 | EmailSignUp( 9 | email: String! 10 | password: String! 11 | firstName: String! 12 | lastName: String! 13 | ): EmailSignUpResponse! 14 | } 15 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/posts/posts.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PostResolvers } from './posts.resolvers'; 3 | import { PostService } from './posts.service'; 4 | import { PrismaService } from 'src/prisma.service'; 5 | 6 | @Module({ 7 | providers: [PostResolvers, PostService, PrismaService], 8 | }) 9 | export class PostModule {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declaration": false, 6 | "removeComments": true, 7 | "sourceMap": false, 8 | "incremental": false 9 | }, 10 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "coverage"] 11 | } 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/.editorconfig: -------------------------------------------------------------------------------- 1 | # https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 4 8 | end_of_line = lf 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [*.{json,yml}] 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-unchecked-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedCreateInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: false }) 9 | name!: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/src/resolvers/index.js: -------------------------------------------------------------------------------- 1 | const {GraphQLDateTime} = require('graphql-iso-date'); 2 | const userResolver = require('./user'); 3 | const postResolver = require('./post'); 4 | 5 | const customScalarResolver = { 6 | Date: GraphQLDateTime, 7 | }; 8 | 9 | 10 | module.exports = [customScalarResolver, userResolver, postResolver ] -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/category/dto/update-category.input.ts: -------------------------------------------------------------------------------- 1 | import { CreateCategoryInput } from './create-category.input'; 2 | import { InputType, Field, Int, PartialType } from '@nestjs/graphql'; 3 | 4 | @InputType() 5 | export class UpdateCategoryInput extends PartialType(CreateCategoryInput) { 6 | @Field(() => Int) 7 | id: number; 8 | } 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class ArticleWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | articleId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | slug?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/delete-many-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereInput } from './article-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyArticleArgs { 7 | @Field(() => ArticleWhereInput, { nullable: true }) 8 | where?: ArticleWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/delete-many-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereInput } from './comment-where.input'; 4 | 5 | @ArgsType() 6 | export class DeleteManyCommentArgs { 7 | @Field(() => CommentWhereInput, { nullable: true }) 8 | where?: CommentWhereInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/delete-one-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneTagArgs { 7 | @Field(() => TagWhereUniqueInput, { nullable: false }) 8 | where!: TagWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/find-unique-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueTagArgs { 7 | @Field(() => TagWhereUniqueInput, { nullable: false }) 8 | where!: TagWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-unchecked-update-many.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedUpdateManyInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-update-many-mutation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUpdateManyMutationInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declaration": false, 6 | "removeComments": true, 7 | "sourceMap": false, 8 | "incremental": false 9 | }, 10 | "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "coverage"] 11 | } 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/create-one-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateInput } from './article-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneArticleArgs { 7 | @Field(() => ArticleCreateInput, { nullable: false }) 8 | data!: ArticleCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/create-one-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentCreateInput } from './comment-create.input'; 4 | 5 | @ArgsType() 6 | export class CreateOneCommentArgs { 7 | @Field(() => CommentCreateInput, { nullable: false }) 8 | data!: CommentCreateInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-create-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagCreateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: false }) 9 | name!: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-update-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUpdateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/delete-one-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserWhereUniqueInput } from './user-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneUserArgs { 7 | @Field(() => UserWhereUniqueInput, { nullable: false }) 8 | where!: UserWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/find-unique-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserWhereUniqueInput } from './user-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueUserArgs { 7 | @Field(() => UserWhereUniqueInput, { nullable: false }) 8 | where!: UserWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/City.ts: -------------------------------------------------------------------------------- 1 | import { CityResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface CityParent { 5 | id: string 6 | name: string 7 | } 8 | 9 | export const City: CityResolvers.Type = { 10 | id: parent => parent.id, 11 | name: parent => parent.name, 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/app_modules/prisma/index.ts: -------------------------------------------------------------------------------- 1 | export { InjectRepository } from './inject-repository.decorator'; 2 | export { PrismaModule } from './prisma.module'; 3 | export { 4 | PrismaModuleAsyncOptions, 5 | PrismaModuleOptions, 6 | PrismaOptionsFactory, 7 | } from './prisma.providers'; 8 | export { PrismaRepository } from './prisma.repository'; 9 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/comment/models/create-comment.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | import { IsNotEmpty } from 'class-validator'; 3 | 4 | /** 5 | * Create comment input object. 6 | */ 7 | @InputType() 8 | export class CreateCommentInput { 9 | @IsNotEmpty() 10 | @Field(() => String) 11 | body: string; 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/generate-typings.ts: -------------------------------------------------------------------------------- 1 | import { GraphQLDefinitionsFactory } from '@nestjs/graphql'; 2 | import { join } from 'path'; 3 | const definitionsFactory = new GraphQLDefinitionsFactory(); 4 | definitionsFactory.generate({ 5 | typePaths: ['./src/**/*.graphql'], 6 | path: join(process.cwd(), 'src/graphql.ts'), 7 | outputAs: 'class', 8 | }); -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { GraphQLModule } from '@nestjs/graphql'; 3 | import { PostModule } from './posts/posts.module'; 4 | 5 | @Module({ 6 | imports: [ 7 | PostModule, 8 | GraphQLModule.forRoot({ 9 | typePaths: ['./**/*.graphql'], 10 | }), 11 | ], 12 | }) 13 | export class AppModule {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/user/user.providers.ts: -------------------------------------------------------------------------------- 1 | import { Connection } from 'mongoose'; 2 | import { UserSchema } from './user.schema'; 3 | 4 | export const userProviders = [ 5 | { 6 | provide: 'USER_MODEL', 7 | useFactory: (connection: Connection) => 8 | connection.model('User', UserSchema), 9 | inject: ['DATABASE_CONNECTION'], 10 | }, 11 | ]; 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/posts/posts.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PostResolvers } from './posts.resolvers'; 3 | import { PostService } from './posts.service'; 4 | import { PrismaService } from 'src/prisma.service'; 5 | 6 | @Module({ 7 | providers: [PostResolvers, PostService, PrismaService], 8 | }) 9 | export class PostModule {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/main.ts: -------------------------------------------------------------------------------- 1 | import { NestFactory } from '@nestjs/core'; 2 | import { AppModule } from './app.module'; 3 | import { Logger } from '@nestjs/common'; 4 | 5 | async function bootstrap() { 6 | const app = await NestFactory.create(AppModule); 7 | await app.listen(3000); 8 | Logger.log('Server start 300', 'Bootstap'); 9 | } 10 | 11 | bootstrap(); 12 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/MutationResult.ts: -------------------------------------------------------------------------------- 1 | import { MutationResultResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface MutationResultParent { 5 | success: boolean 6 | } 7 | 8 | export const MutationResult: MutationResultResolvers.Type = { 9 | success: parent => parent.success, 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/src/schema/index.js: -------------------------------------------------------------------------------- 1 | import {gql} from 'apollo-server-express'; 2 | import userSchema from './user'; 3 | 4 | const baseSchema = gql` 5 | scalar Date 6 | 7 | type Query { 8 | _: Boolean 9 | } 10 | 11 | type Mutation { 12 | _: Boolean 13 | } 14 | 15 | type Subscription { 16 | _: Boolean 17 | } 18 | `; 19 | export default [baseSchema, userSchema] -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class UserOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/config/config.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { ConfigService } from './config.service'; 3 | 4 | @Module({ 5 | providers: [ 6 | { 7 | provide: ConfigService, 8 | useValue: new ConfigService('.env'), 9 | }, 10 | ], 11 | exports: [ConfigService], 12 | }) 13 | export class ConfigModule {} 14 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/Picture.ts: -------------------------------------------------------------------------------- 1 | import { PictureResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface PictureParent { 5 | id: string 6 | url: string 7 | } 8 | 9 | export const Picture: PictureResolvers.Type = { 10 | id: parent => parent.id, 11 | url: parent => parent.url, 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/delete-one-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneArticleArgs { 7 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 8 | where!: ArticleWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/delete-one-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class DeleteOneCommentArgs { 7 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 8 | where!: CommentWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-unchecked-create-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedCreateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: false }) 9 | name!: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-unchecked-update-many-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedUpdateManyWithoutTagsInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-unchecked-update-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagUncheckedUpdateWithoutArticlesInput { 5 | @Field(() => String, { nullable: true }) 6 | tagId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | name?: string; 10 | } 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/prisma/migrations/20220421085319_/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "Post" ( 3 | "id" SERIAL NOT NULL, 4 | "title" TEXT NOT NULL, 5 | "content" TEXT NOT NULL, 6 | "published" BOOLEAN NOT NULL DEFAULT false, 7 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 8 | 9 | PRIMARY KEY ("id") 10 | ); 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/app.controller.ts: -------------------------------------------------------------------------------- 1 | import { Controller, Get } from '@nestjs/common'; 2 | import { AppService } from './app.service'; 3 | 4 | @Controller() 5 | export class AppController { 6 | constructor(private readonly appService: AppService) {} 7 | 8 | @Get() 9 | getHello(): string { 10 | return this.appService.getHello(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/src/graphql/subscriptions.js: -------------------------------------------------------------------------------- 1 | import { gql } from '@apollo/client'; 2 | 3 | export const POSTS_SUBSCRIPTION = gql` 4 | subscription { 5 | post { 6 | mutation 7 | data { 8 | title 9 | body 10 | author { 11 | name 12 | } 13 | published 14 | } 15 | } 16 | } 17 | `; 18 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/main.ts: -------------------------------------------------------------------------------- 1 | import { ValidationPipe } from '@nestjs/common'; 2 | import { NestFactory } from '@nestjs/core'; 3 | import { AppModule } from './app.module'; 4 | 5 | async function bootstrap() { 6 | const app = await NestFactory.create(AppModule); 7 | app.useGlobalPipes(new ValidationPipe()); 8 | await app.listen(3000); 9 | } 10 | bootstrap(); 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-avg-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleAvgOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | favoritesCount?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-sum-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class ArticleSumOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | favoritesCount?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/find-unique-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueArticleArgs { 7 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 8 | where!: ArticleWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/comment-order-by-relation-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class CommentOrderByRelationAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | _count?: keyof typeof SortOrder; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/find-unique-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 4 | 5 | @ArgsType() 6 | export class FindUniqueCommentArgs { 7 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 8 | where!: CommentWhereUniqueInput; 9 | } 10 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | mongo: 4 | image: mongo 5 | container_name: global-mongo-service 6 | restart: unless-stopped 7 | volumes: 8 | - mongo_data:/data/configdb 9 | - mongo_data:/data/db 10 | ports: 11 | - 27017:27017 12 | volumes: 13 | mongo_data: {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { GraphQLModule } from '@nestjs/graphql'; 3 | import { PostModule } from './posts/posts.module'; 4 | 5 | @Module({ 6 | imports: [ 7 | PostModule, 8 | GraphQLModule.forRoot({ 9 | typePaths: ['./**/*.graphql'], 10 | }), 11 | ], 12 | }) 13 | export class AppModule {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/api/league/league.graphql: -------------------------------------------------------------------------------- 1 | type League{ 2 | id: ID! 3 | name:String! 4 | pokemons: [Pokemon!] 5 | } 6 | 7 | type Query{ 8 | leagues: [League!] 9 | league(id: ID): League! 10 | } 11 | 12 | type Mutation { 13 | createLeague(name: String!): League 14 | updateLeague(id: ID, name: String!): League 15 | deleteLeague(id: ID): Deleted 16 | } 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | setupFiles: ['/test/setEnvVars.js'], 3 | silent: false, 4 | moduleFileExtensions: ['js', 'ts'], 5 | rootDir: '.', 6 | testRegex: '[.](spec|test).ts$', 7 | transform: { 8 | '^.+\\.(t|j)s$': 'ts-jest', 9 | }, 10 | coverageDirectory: './coverage', 11 | testEnvironment: 'node', 12 | roots: ['/'] 13 | }; -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | import { DomainModule } from './domain/domain.module'; 5 | 6 | @Module({ 7 | imports: [DomainModule], 8 | controllers: [AppController], 9 | providers: [AppService], 10 | }) 11 | export class AppModule { } 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/employee/dto/create-employee.input.ts: -------------------------------------------------------------------------------- 1 | import { InputType, Int, Field } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CreateEmployeeInput { 5 | 6 | 7 | @Field() 8 | firstname: string; 9 | 10 | @Field() 11 | lastname: string; 12 | 13 | @Field() 14 | designation: string; 15 | 16 | @Field({nullable:true}) 17 | city: string; 18 | } 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | printWidth: 88, 3 | trailingComma: 'all', 4 | tabWidth: 4, 5 | semi: true, 6 | singleQuote: true, 7 | arrowParens: 'avoid', 8 | overrides: [ 9 | { 10 | files: '*.{json,yml}', 11 | options: { 12 | tabWidth: 2, 13 | }, 14 | }, 15 | ], 16 | }; 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | setupFiles: ['/test/setEnvVars.js'], 3 | silent: false, 4 | moduleFileExtensions: ['js', 'ts'], 5 | rootDir: '.', 6 | testRegex: '[.](spec|test).ts$', 7 | transform: { 8 | '^.+\\.(t|j)s$': 'ts-jest', 9 | }, 10 | coverageDirectory: './coverage', 11 | testEnvironment: 'node', 12 | roots: ['/'] 13 | }; -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/PlaceViews.ts: -------------------------------------------------------------------------------- 1 | import { PlaceViewsResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface PlaceViewsParent { 5 | id: string 6 | lastWeek: number 7 | } 8 | 9 | export const PlaceViews: PlaceViewsResolvers.Type = { 10 | id: parent => parent.id, 11 | lastWeek: parent => parent.lastWeek, 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/database/database.providers.ts: -------------------------------------------------------------------------------- 1 | // src/database/database.providers.ts 2 | import mongoose from 'mongoose'; 3 | import { MONO_DB_CONNECTION_STRING } from '../constants'; 4 | 5 | export const databaseProviders = [ 6 | { 7 | provide: 'DATABASE_CONNECTION', 8 | useFactory: (): Promise => 9 | mongoose.connect(MONO_DB_CONNECTION_STRING), 10 | }, 11 | ]; 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-order-by.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagOrderByInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/generate-typings.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | var graphql_1 = require("@nestjs/graphql"); 4 | var path_1 = require("path"); 5 | var definitionsFactory = new graphql_1.GraphQLDefinitionsFactory(); 6 | definitionsFactory.generate({ 7 | typePaths: ['./src/**/*.graphql'], 8 | path: path_1.join(process.cwd(), 'src/graphql.ts'), 9 | outputAs: 'class' 10 | }); 11 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/article/types/article.ts: -------------------------------------------------------------------------------- 1 | import { ArticleAuthor } from './article-author'; 2 | 3 | export interface Article { 4 | slug: string; 5 | title: string; 6 | description: string; 7 | body: string; 8 | tagList: string[]; 9 | createdAt: Date; 10 | updatedAt: Date; 11 | favorited: boolean; 12 | favoritesCount: number; 13 | author: ArticleAuthor; 14 | } 15 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/tag/tag.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PrismaModule } from 'app_modules/prisma'; 3 | 4 | import { TagResolver } from './tag.resolver'; 5 | import { TagService } from './tag.service'; 6 | 7 | @Module({ 8 | imports: [PrismaModule], 9 | providers: [TagResolver, TagService], 10 | exports: [TagService], 11 | }) 12 | export class TagModule {} 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/app.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { AppController } from './app.controller'; 3 | import { AppService } from './app.service'; 4 | import { DomainModule } from './modules/domain/domain.module'; 5 | 6 | @Module({ 7 | imports: [DomainModule], 8 | controllers: [AppController], 9 | providers: [AppService], 10 | }) 11 | export class AppModule { } 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/modules/domain/league/league.graphql: -------------------------------------------------------------------------------- 1 | type League { 2 | id: ID! 3 | name:String! 4 | pokemons: [Pokemon!] 5 | } 6 | 7 | type Query { 8 | leagues: [League!] 9 | league(id: ID): League! 10 | } 11 | 12 | type Mutation { 13 | createLeague(name: String!): League 14 | updateLeague(id: ID!, name: String!): League 15 | deleteLeague(id: ID): Deleted 16 | } 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-count-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class TagCountAggregateInput { 5 | @Field(() => Boolean, { nullable: true }) 6 | tagId?: true; 7 | 8 | @Field(() => Boolean, { nullable: true }) 9 | name?: true; 10 | 11 | @Field(() => Boolean, { nullable: true }) 12 | _all?: true; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-count-aggregate.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class TagCountAggregate { 5 | @Field(() => Int, { nullable: false }) 6 | tagId!: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | name!: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | _all!: number; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/article/author.guard.spec.ts: -------------------------------------------------------------------------------- 1 | import { ArticleService } from './article.service'; 2 | import { AuthorGuard } from './author.guard'; 3 | 4 | describe('AuthorGuard', () => { 5 | it('should be defined', () => { 6 | const { ArticleService } = jest.createMockFromModule('./article.service'); 7 | expect(new AuthorGuard(new ArticleService())).toBeDefined(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-folder-restructuring-05/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | import {users, comments, posts} from '../db'; 2 | 3 | const Comment = { 4 | author(parent, args, ctx, info) { 5 | return users.find((i) => i.id === parent.author); 6 | }, 7 | post(parent, args, ctx, info) { 8 | return posts.find((i) => i.id === parent.post); 9 | } 10 | } 11 | 12 | export default Comment; -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/utils/privateResolver.ts: -------------------------------------------------------------------------------- 1 | const privateResolver = resolverFunction => async ( 2 | parent, 3 | args, 4 | context, 5 | info 6 | ) => { 7 | if (!context.req.user) { 8 | throw new Error("No JWT. I refuse to proceed"); 9 | } 10 | 11 | const resolved = await resolverFunction(parent, args, context, info); 12 | return resolved; 13 | }; 14 | 15 | export default privateResolver; 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-count.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class ArticleCount { 5 | @Field(() => Int, { nullable: false }) 6 | tags!: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | favoritedBy!: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | comments!: number; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-where-unique.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class UserWhereUniqueInput { 5 | @Field(() => String, { nullable: true }) 6 | userId?: string; 7 | 8 | @Field(() => String, { nullable: true }) 9 | email?: string; 10 | 11 | @Field(() => String, { nullable: true }) 12 | name?: string; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/fragments/comment.ts: -------------------------------------------------------------------------------- 1 | import { userFields } from './user'; 2 | 3 | export const commentFields = /* GraphQL */ ` 4 | fragment commentFields on Comment { 5 | id: commentId 6 | createdAt 7 | updatedAt 8 | body 9 | author { 10 | ...userFields 11 | following: isFollowing 12 | } 13 | } 14 | ${userFields} 15 | `; 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/comment/comment.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | 3 | import { ArticleModule } from '../article/article.module'; 4 | import { CommentResolver } from './comment.resolver'; 5 | import { CommentService } from './comment.service'; 6 | 7 | @Module({ 8 | imports: [ArticleModule], 9 | providers: [CommentService, CommentResolver], 10 | }) 11 | export class CommentModule {} 12 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/hello-world/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | import {users, comments, posts} from '../db'; 2 | 3 | const Post = { 4 | author(parent, args, ctx, info) { 5 | return users.find((i) => i.id === parent.author); 6 | }, 7 | comments(parent, args, ctx, info) { 8 | return comments.comments.filter((comment) => { 9 | return comment.post === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export default Post; -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/src/model/index.js: -------------------------------------------------------------------------------- 1 | import mongoose from "mongoose" 2 | import User from './user'; 3 | import Message from './message'; 4 | 5 | 6 | const connectMongo = () =>{ 7 | console.log(process.env.MONGO_URL); 8 | return mongoose.connect(process.env.MONGO_URL, { useUnifiedTopology: true }) 9 | } 10 | 11 | const models = { User, Message }; 12 | 13 | export { connectMongo }; 14 | 15 | export default models; -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/generate-typings.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | var graphql_1 = require("@nestjs/graphql"); 4 | var path_1 = require("path"); 5 | var definitionsFactory = new graphql_1.GraphQLDefinitionsFactory(); 6 | definitionsFactory.generate({ 7 | typePaths: ['./src/**/*.graphql'], 8 | path: path_1.join(process.cwd(), 'src/graphql.ts'), 9 | outputAs: 'class' 10 | }); 11 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/CityPreviousValues.ts: -------------------------------------------------------------------------------- 1 | import { CityPreviousValuesResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface CityPreviousValuesParent { 5 | id: string 6 | name: string 7 | } 8 | 9 | export const CityPreviousValues: CityPreviousValuesResolvers.Type = { 10 | id: parent => parent.id, 11 | name: parent => parent.name, 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "target": "es6", 9 | "sourceMap": true, 10 | "outDir": "./dist", 11 | "baseUrl": "./", 12 | "incremental": true 13 | }, 14 | "exclude": ["node_modules"] 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserWhereInput } from './user-where.input'; 4 | 5 | @InputType() 6 | export class UserRelationFilter { 7 | @Field(() => UserWhereInput, { nullable: true }) 8 | is?: UserWhereInput; 9 | 10 | @Field(() => UserWhereInput, { nullable: true }) 11 | isNot?: UserWhereInput; 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/schema.gpl: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------- 2 | # !!! THIS FILE WAS GENERATED BY TYPE-GRAPHQL !!! 3 | # !!! DO NOT MODIFY THIS FILE BY YOURSELF !!! 4 | # ----------------------------------------------- 5 | 6 | type CreatePokemonDto { 7 | id: String! 8 | name: String! 9 | type: String! 10 | pokedex: Float! 11 | } 12 | 13 | type Query { 14 | pokemon: [CreatePokemonDto!]! 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/project/dto/update-project.input.ts: -------------------------------------------------------------------------------- 1 | import { CreateProjectInput } from './create-project.input'; 2 | import { InputType, Field, Int, PartialType } from '@nestjs/graphql'; 3 | 4 | @InputType() 5 | export class UpdateProjectInput extends PartialType(CreateProjectInput) { 6 | @Field() 7 | id: number; 8 | 9 | @Field() 10 | name: string; 11 | 12 | @Field(() => Int) 13 | code: number; 14 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-server/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | const Comment = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | post(parent, args, { db }, info) { 8 | return db.posts.find((post) => { 9 | return post.id === parent.post 10 | }) 11 | } 12 | } 13 | 14 | export { Comment as default } -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/src/model/message.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | 3 | const messageSchema = new mongoose.Schema( 4 | { 5 | text: { 6 | type: String, 7 | required: true, 8 | }, 9 | userId: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, 10 | }, 11 | { 12 | timestamps: true, 13 | }, 14 | ); 15 | 16 | const Message = mongoose.model('Message', messageSchema); 17 | 18 | export default Message; 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/docker-compose.override.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | postgres: 4 | environment: 5 | - POSTGRES_USER=api 6 | - POSTGRES_PASSWORD=development_pass 7 | - POSTGRES_MULTIPLE_DATABASES="example-api","example-api-testing" 8 | volumes: 9 | - ./docker-utils:/docker-entrypoint-initdb.d 10 | - api_data:/data/postgres 11 | ports: 12 | - 5434:5432 13 | volumes: 14 | api_data: {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/jest.config-e2e.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "setupFiles": [ 3 | "/test/setEnvVars.js" 4 | ], 5 | "moduleFileExtensions": [ 6 | "js", 7 | "ts" 8 | ], 9 | "rootDir": ".", 10 | "testRegex": "[.]spec.ts$", 11 | "transform": { 12 | "^.+\\.(t|j)s$": "ts-jest" 13 | }, 14 | "coverageDirectory": "./coverage", 15 | "testEnvironment": "node", 16 | "roots": [ 17 | "/" 18 | ] 19 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum UserScalarFieldEnum { 4 | userId = 'userId', 5 | email = 'email', 6 | name = 'name', 7 | password = 'password', 8 | bio = 'bio', 9 | image = 'image', 10 | } 11 | 12 | registerEnumType(UserScalarFieldEnum, { 13 | name: 'UserScalarFieldEnum', 14 | description: undefined, 15 | }); 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/docker-compose.override.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | postgres: 4 | environment: 5 | - POSTGRES_USER=api 6 | - POSTGRES_PASSWORD=development_pass 7 | - POSTGRES_MULTIPLE_DATABASES="example-api","example-api-testing" 8 | volumes: 9 | - ./docker-utils:/docker-entrypoint-initdb.d 10 | - api_data:/data/postgres 11 | ports: 12 | - 5434:5432 13 | volumes: 14 | api_data: {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/jest.config-e2e.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "setupFiles": [ 3 | "/test/setEnvVars.js" 4 | ], 5 | "moduleFileExtensions": [ 6 | "js", 7 | "ts" 8 | ], 9 | "rootDir": ".", 10 | "testRegex": "[.]spec.ts$", 11 | "transform": { 12 | "^.+\\.(t|j)s$": "ts-jest" 13 | }, 14 | "coverageDirectory": "./coverage", 15 | "testEnvironment": "node", 16 | "roots": [ 17 | "/" 18 | ] 19 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-server/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | const Post = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.post === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { Post as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-server/src/resolvers/User.js: -------------------------------------------------------------------------------- 1 | const User = { 2 | posts(parent, args, { db }, info) { 3 | return db.posts.filter((post) => { 4 | return post.author === parent.id 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.author === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { User as default } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-max-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagMaxOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: keyof typeof SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-min-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagMinOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: keyof typeof SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/docker-compose.override.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | postgres: 4 | environment: 5 | - POSTGRES_USER=api 6 | - POSTGRES_PASSWORD=development_pass 7 | - POSTGRES_MULTIPLE_DATABASES="example-api","example-api-testing" 8 | volumes: 9 | - ./docker-utils:/docker-entrypoint-initdb.d 10 | - api_data:/data/postgres 11 | ports: 12 | - 5434:5432 13 | volumes: 14 | api_data: {} -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "target": "es2017", 9 | "sourceMap": true, 10 | "outDir": "./dist", 11 | "baseUrl": "./", 12 | "incremental": true 13 | }, 14 | "exclude": [ 15 | "node_modules", 16 | "dist" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/project/project.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require('mongoose') 2 | const projectSchema = new mongoose.Schema({ 3 | name: { 4 | type: String, 5 | required: true, 6 | unique: true 7 | }, 8 | description: { 9 | type: String, 10 | trim: true 11 | } 12 | }, {timestamps: true}) 13 | 14 | projectSchema.index({name: 'text'}) 15 | 16 | module.exports = mongoose.model('project', projectSchema) 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/src/schema/index.js: -------------------------------------------------------------------------------- 1 | const {gql} = require('apollo-server-express'); 2 | 3 | const User = require('./user'); 4 | const Post = require('./post'); 5 | const Tag = require('./tag'); 6 | const baseSchema = gql` 7 | scalar Date 8 | 9 | type Query { 10 | _: Boolean 11 | } 12 | 13 | type Mutation { 14 | _: Boolean 15 | } 16 | 17 | type Subscription { 18 | _: Boolean 19 | } 20 | `; 21 | module.exports = [baseSchema, User, Post, Tag] -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "es2017", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereInput } from './article-where.input'; 4 | 5 | @InputType() 6 | export class ArticleRelationFilter { 7 | @Field(() => ArticleWhereInput, { nullable: true }) 8 | is?: ArticleWhereInput; 9 | 10 | @Field(() => ArticleWhereInput, { nullable: true }) 11 | isNot?: ArticleWhereInput; 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-count-order-by-aggregate.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { SortOrder } from '../prisma/sort-order.enum'; 4 | 5 | @InputType() 6 | export class TagCountOrderByAggregateInput { 7 | @Field(() => SortOrder, { nullable: true }) 8 | tagId?: keyof typeof SortOrder; 9 | 10 | @Field(() => SortOrder, { nullable: true }) 11 | name?: keyof typeof SortOrder; 12 | } 13 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/README.md: -------------------------------------------------------------------------------- 1 | A GraphQL API built on top of NestJS and containerized by Docker. 2 | 3 | The application was built for the [Build a Scalable GraphQL Server With NestJS, MongoDB & TypeScript](https://tomanagle.medium.com/build-a-scalable-graphql-server-with-nestjs-mongodb-typescript-1eeda049f7c8) tutorial. 4 | 5 | ### Getting started 6 | Start the application 7 | 8 | `yarn dev` 9 | 10 | Build and start the container 11 | 12 | `docker-compose up` 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/.releaserc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | '@semantic-release/commit-analyzer', 4 | '@semantic-release/release-notes-generator', 5 | '@semantic-release/changelog', 6 | [ 7 | '@semantic-release/npm', 8 | { 9 | pkgRoot: 'dist', 10 | }, 11 | ], 12 | '@semantic-release/github', 13 | '@semantic-release/git', 14 | ], 15 | }; 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/user/models/user-login.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | /** 4 | * Credentials DTO object. 5 | */ 6 | @InputType() 7 | export class UserLoginInput { 8 | @Field(() => String, { 9 | description: undefined, 10 | }) 11 | email: string; 12 | 13 | @Field(() => String, { 14 | nullable: false, 15 | description: undefined, 16 | }) 17 | password: string; 18 | } 19 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-folder-restructuring-05/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | import {users, comments, posts} from '../db'; 2 | 3 | const Post = { 4 | author(parent, args, ctx, info) { 5 | return users.find((i) => i.id === parent.author); 6 | }, 7 | comments(parent, args, ctx, info) { 8 | return comments.comments.filter((comment) => { 9 | return comment.post === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export default Post; -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/setup-01/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-basics", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "babel-node src/index.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "babel-cli": "^6.26.0", 14 | "babel-preset-env": "^1.7.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["tslint:recommended", "tslint-config-prettier"], 3 | "linterOptions": { 4 | "exclude": ["config/**/*.js", "node_modules/**/*."] 5 | }, 6 | "rules": { 7 | "no-console": false, 8 | "member-access": false, 9 | "object-literal-sort-keys": false, 10 | "ordered-imports": true, 11 | "interface-name": false, 12 | "strict-null-checks": false 13 | }, 14 | "rulesDirectory": [] 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "es2017", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/AuthPayload.ts: -------------------------------------------------------------------------------- 1 | import { AuthPayloadResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | import { UserParent } from './User' 4 | 5 | export interface AuthPayloadParent { 6 | id: string 7 | token: string 8 | } 9 | 10 | export const AuthPayload: AuthPayloadResolvers.Type = { 11 | token: parent => parent.token, 12 | user: (parent, _args, ctx) => ctx.db.user({ id: parent.id }) 13 | } 14 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-apis-08/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | const Comment = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | post(parent, args, { db }, info) { 8 | return db.posts.find((post) => { 9 | return post.id === parent.post 10 | }) 11 | } 12 | } 13 | 14 | export { Comment as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-posts-09/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | const Comment = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | post(parent, args, { db }, info) { 8 | return db.posts.find((post) => { 9 | return post.id === parent.post 10 | }) 11 | } 12 | } 13 | 14 | export { Comment as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-queries-07/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | const Comment = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | post(parent, args, { db }, info) { 8 | return db.posts.find((post) => { 9 | return post.id === parent.post 10 | }) 11 | } 12 | } 13 | 14 | export { Comment as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/tests/run.js: -------------------------------------------------------------------------------- 1 | const { typeDefs, resolvers, context } = require('../src/api') 2 | const { makeExecutableSchema } = require('graphql-tools') 3 | const { graphql } = require('graphql') 4 | 5 | const runQuery = (query, variables = {}, ctx = {}) => { 6 | const schema = makeExecutableSchema({typeDefs, resolvers}) 7 | return graphql(schema, query, null, {...context, ...ctx}, variables) 8 | } 9 | 10 | module.exports = { 11 | runQuery 12 | } 13 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-apis-08/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | const Post = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.post === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { Post as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-apis-08/src/resolvers/User.js: -------------------------------------------------------------------------------- 1 | const User = { 2 | posts(parent, args, ctx, info) { 3 | return db.posts.filter((post) => { 4 | return post.author === parent.id 5 | }) 6 | }, 7 | comments(parent, args, ctx, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.author === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { User as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-queries-07/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | const Post = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.post === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { Post as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-subscription-10/src/resolvers/Comment.js: -------------------------------------------------------------------------------- 1 | const Comment = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | post(parent, args, { db }, info) { 8 | return db.posts.find((post) => { 9 | return post.id === parent.post 10 | }) 11 | } 12 | } 13 | 14 | export { Comment as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/ormConfig.ts: -------------------------------------------------------------------------------- 1 | import { ConnectionOptions } from "typeorm"; 2 | 3 | const connectionOptions: ConnectionOptions = { 4 | type: "postgres", 5 | database: process.env.DB_NAME, 6 | synchronize: true, 7 | logging: true, 8 | entities: ["entities/**/*.*"], 9 | host: process.env.DB_ENDPOINT, 10 | port: 5432, 11 | username: process.env.DB_USERNAME, 12 | password: process.env.DB_PASSWORD 13 | }; 14 | 15 | export default connectionOptions; 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/.env: -------------------------------------------------------------------------------- 1 | # Environment variables declared in this file are automatically made available to Prisma. 2 | # See the documentation for more detail: https://pris.ly/d/prisma-schema#using-environment-variables 3 | 4 | # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server (Preview) and MongoDB (Preview). 5 | # See the documentation for all the connection string options: https://pris.ly/d/connection-strings 6 | 7 | DATABASE_URL="file:./dev.db" -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12-buster-slim 2 | 3 | WORKDIR /app 4 | 5 | COPY package.json package-lock.json /app/ 6 | 7 | RUN npm install && \ 8 | rm -rf /tmp/* /var/tmp/* 9 | 10 | COPY ./docker-utils/entrypoint/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh 11 | 12 | COPY . /app 13 | 14 | RUN npm run build 15 | 16 | EXPOSE 3000 17 | 18 | USER node 19 | 20 | ENV TYPEORM_MIGRATION=ENABLE 21 | ENV NPM_INSTALL=DISABLE 22 | CMD npm run start:prod -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/tag/tag.resolver.ts: -------------------------------------------------------------------------------- 1 | import { Query, Resolver } from '@nestjs/graphql'; 2 | 3 | import { Tag } from './tag.model'; 4 | import { TagService } from './tag.service'; 5 | 6 | /** 7 | * Resolves tag object type. 8 | */ 9 | @Resolver() 10 | export class TagResolver { 11 | constructor(private readonly tagService: TagService) {} 12 | 13 | @Query(() => [Tag]) 14 | async tags() { 15 | return this.tagService.findMany(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "allowSyntheticDefaultImports": true, 9 | "target": "es2017", 10 | "sourceMap": true, 11 | "outDir": "./dist", 12 | "baseUrl": "./", 13 | "incremental": true, 14 | "skipLibCheck": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12-buster-slim 2 | 3 | WORKDIR /app 4 | 5 | COPY package.json package-lock.json /app/ 6 | 7 | RUN npm install && \ 8 | rm -rf /tmp/* /var/tmp/* 9 | 10 | COPY ./docker-utils/entrypoint/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh 11 | 12 | COPY . /app 13 | 14 | RUN npm run build 15 | 16 | EXPOSE 3000 17 | 18 | USER node 19 | 20 | ENV TYPEORM_MIGRATION=ENABLE 21 | ENV NPM_INSTALL=DISABLE 22 | CMD npm run start:prod -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-posts-09/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | const Post = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.post === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { Post as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-blog-posts-09/src/resolvers/User.js: -------------------------------------------------------------------------------- 1 | const User = { 2 | posts(parent, args, { db }, info) { 3 | return db.posts.filter((post) => { 4 | return post.author === parent.id 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.author === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { User as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-queries-07/src/resolvers/User.js: -------------------------------------------------------------------------------- 1 | const User = { 2 | posts(parent, args, { db }, info) { 3 | return db.posts.filter((post) => { 4 | return post.author === parent.id 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.author === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { User as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-subscription-10/src/resolvers/Post.js: -------------------------------------------------------------------------------- 1 | const Post = { 2 | author(parent, args, { db }, info) { 3 | return db.users.find((user) => { 4 | return user.id === parent.author 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.post === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { Post as default } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/hello-world/src/resolvers/User.js: -------------------------------------------------------------------------------- 1 | import {users, comments, posts} from '../db'; 2 | 3 | const User = { 4 | posts(parent, args, ctx, info) { 5 | return users.posts.filter((post) => { 6 | return post.author === parent.id 7 | }) 8 | }, 9 | comments(parent, args, ctx, info) { 10 | return users.comments.filter((comment) => { 11 | return comment.author === parent.id 12 | }) 13 | } 14 | } 15 | 16 | export default User; -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/user/testing/index.ts: -------------------------------------------------------------------------------- 1 | import { Prisma } from '@prisma/client'; 2 | 3 | type UserPayload = Prisma.UserGetPayload; 4 | 5 | export function createUser(parts: Partial = {}): UserPayload { 6 | return { 7 | userId: 'user_id', 8 | email: 'user_email', 9 | name: 'user_name', 10 | password: 'user_password', 11 | bio: 'user_bio', 12 | image: 'user_image', 13 | ...parts, 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-subscription-10/src/resolvers/User.js: -------------------------------------------------------------------------------- 1 | const User = { 2 | posts(parent, args, { db }, info) { 3 | return db.posts.filter((post) => { 4 | return post.author === parent.id 5 | }) 6 | }, 7 | comments(parent, args, { db }, info) { 8 | return db.comments.filter((comment) => { 9 | return comment.author === parent.id 10 | }) 11 | } 12 | } 13 | 14 | export { User as default } -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/src/schema/message.js: -------------------------------------------------------------------------------- 1 | import { gql } from 'apollo-server-express'; 2 | 3 | export default gql` 4 | type Message { 5 | text: String! 6 | userId: String! 7 | } 8 | extend type Query { 9 | messages: [Messages!] 10 | message(id: ID!): Message 11 | } 12 | extend type Mutation { 13 | signIn(login: String!, password: String!): Token! 14 | updateUser(username: String!): User! 15 | deleteUser(id: ID!): Boolean! 16 | } 17 | ` -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:12-buster-slim 2 | 3 | WORKDIR /app 4 | 5 | COPY package.json package-lock.json /app/ 6 | 7 | RUN npm install && \ 8 | rm -rf /tmp/* /var/tmp/* 9 | 10 | COPY ./docker-utils/entrypoint/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh 11 | 12 | COPY . /app 13 | 14 | RUN npm run build 15 | 16 | EXPOSE 3000 17 | 18 | USER node 19 | 20 | ENV TYPEORM_MIGRATION=ENABLE 21 | ENV NPM_INSTALL=DISABLE 22 | CMD npm run start:prod -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/server.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config() 2 | const { GraphQLServer } = require('graphql-yoga') 3 | const gqlServerConfig = require('./api') 4 | require('./db')() 5 | 6 | const serverOptions = { 7 | port: 5000, 8 | endpoint: '/graphql', 9 | playground: '/docs', 10 | tracing: true, 11 | debug: true 12 | } 13 | 14 | const server = new GraphQLServer(gqlServerConfig) 15 | server.start(serverOptions, ({port}) => console.log(`Server on port ${port}`)) 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/prisma.service.ts: -------------------------------------------------------------------------------- 1 | import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common'; 2 | import { PrismaClient } from '@prisma/client'; 3 | 4 | @Injectable() 5 | export class PrismaService extends PrismaClient implements OnModuleInit { 6 | async onModuleInit() { 7 | await this.$connect(); 8 | } 9 | 10 | async enableShutdownHooks(app: INestApplication) { 11 | this.$on('beforeExit', async () => { 12 | await app.close(); 13 | }); 14 | } 15 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/user/user.module.ts: -------------------------------------------------------------------------------- 1 | // src/user/user.module.ts 2 | import { Module } from '@nestjs/common'; 3 | import { UserResolver } from './user.resolver'; 4 | import { UserService } from './user.service'; 5 | import { DatabaseModule } from '../database/database.module'; 6 | import { userProviders } from './user.providers'; 7 | 8 | @Module({ 9 | imports: [DatabaseModule], 10 | providers: [UserResolver, UserService, ...userProviders], 11 | }) 12 | export class UserModule {} 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "esModuleInterop": true, 9 | "skipLibCheck": true, 10 | "target": "es2017", 11 | "sourceMap": true, 12 | "outDir": "./dist", 13 | "baseUrl": "./", 14 | "incremental": true 15 | }, 16 | "exclude": ["node_modules", "dist"] 17 | } 18 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/comment-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum CommentScalarFieldEnum { 4 | commentId = 'commentId', 5 | createdAt = 'createdAt', 6 | updatedAt = 'updatedAt', 7 | body = 'body', 8 | authorId = 'authorId', 9 | articleId = 'articleId', 10 | } 11 | 12 | registerEnumType(CommentScalarFieldEnum, { 13 | name: 'CommentScalarFieldEnum', 14 | description: undefined, 15 | }); 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/api/league/league.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { LeagueResolver } from './league.resolver'; 3 | import { LeagueService } from './league.service'; 4 | import { TypeOrmModule } from '@nestjs/typeorm'; 5 | import { LeagueEntity } from '../../entity/league.entity'; 6 | 7 | @Module({ 8 | imports: [TypeOrmModule.forFeature([LeagueEntity])], 9 | providers: [LeagueResolver, LeagueService], 10 | }) 11 | export class LeagueModule { 12 | } 13 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/github.js: -------------------------------------------------------------------------------- 1 | const octokit = require('@octokit/rest')() 2 | 3 | if (process.env.NODE_ENV !== 'testing') { 4 | octokit.authenticate({ 5 | type: 'token', 6 | token: process.env.GITHUB_TOKEN 7 | }) 8 | } 9 | 10 | const reposForOrg = () => { 11 | return octokit.repos.getForOrg({ 12 | org: 'tipeio', 13 | type: 'public' 14 | }).then(({data}) => { 15 | return data 16 | }) 17 | } 18 | 19 | module.exports = { 20 | reposForOrg 21 | } 22 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/employee/employee.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { EmployeeService } from './employee.service'; 3 | import { EmployeeResolver } from './employee.resolver'; 4 | import { TypeOrmModule } from '@nestjs/typeorm'; 5 | import { Employee } from './entities/employee.entity'; 6 | 7 | @Module({ 8 | imports:[TypeOrmModule.forFeature([Employee])], 9 | providers: [EmployeeResolver, EmployeeService] 10 | }) 11 | export class EmployeeModule {} 12 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/update-one-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagUpdateInput } from './tag-update.input'; 4 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneTagArgs { 8 | @Field(() => TagUpdateInput, { nullable: false }) 9 | data!: TagUpdateInput; 10 | 11 | @Field(() => TagWhereUniqueInput, { nullable: false }) 12 | where!: TagWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/category/category.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { CategoryService } from './category.service'; 3 | import { CategoryResolver } from './category.resolver'; 4 | import { Category } from './entities/category.entity'; 5 | import { TypeOrmModule } from '@nestjs/typeorm'; 6 | 7 | @Module({ 8 | imports:[TypeOrmModule.forFeature([Category])], 9 | 10 | providers: [CategoryResolver, CategoryService] 11 | }) 12 | export class CategoryModule {} 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/modules/domain/league/league.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { LeagueResolver } from './league.resolver'; 3 | import { LeagueService } from './league.service'; 4 | import { TypeOrmModule } from '@nestjs/typeorm'; 5 | import { LeagueEntity } from '../entity/league.entity'; 6 | 7 | @Module({ 8 | imports: [TypeOrmModule.forFeature([LeagueEntity])], 9 | providers: [LeagueResolver, LeagueService], 10 | }) 11 | export class LeagueModule { 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/api/pokemon/pokemon.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PokemonService } from './pokemon.service'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { PokemonEntity } from '../../entity/pokemon.entity'; 5 | import { PokemonResolver } from './pokemon.resolver'; 6 | 7 | @Module({ 8 | imports: [TypeOrmModule.forFeature([PokemonEntity])], 9 | providers: [PokemonService, PokemonResolver], 10 | }) 11 | export class PokemonModule { 12 | } 13 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/update-one-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateInput } from './user-update.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneUserArgs { 8 | @Field(() => UserUpdateInput, { nullable: false }) 9 | data!: UserUpdateInput; 10 | 11 | @Field(() => UserWhereUniqueInput, { nullable: false }) 12 | where!: UserWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-example/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "declaration": true, 5 | "removeComments": true, 6 | "emitDecoratorMetadata": true, 7 | "experimentalDecorators": true, 8 | "target": "es2017", 9 | "sourceMap": true, 10 | "outDir": "./dist", 11 | "baseUrl": "./", 12 | "incremental": true, 13 | "resolveJsonModule": true, 14 | "skipLibCheck": true 15 | }, 16 | "exclude": [ 17 | "node_modules", 18 | "dist" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/src/prisma.service.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common'; 4 | import { PrismaClient } from '@prisma/client'; 5 | 6 | @Injectable() 7 | export class PrismaService extends PrismaClient implements OnModuleInit { 8 | async onModuleInit() { 9 | await this.$connect(); 10 | } 11 | async enableShutdownHooks(app: INestApplication) { 12 | this.$on('beforeExit', async () => { 13 | await app.close(); 14 | }) 15 | } 16 | } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-folder-restructuring-05/src/resolvers/User.js: -------------------------------------------------------------------------------- 1 | import {users, comments, posts} from '../db'; 2 | 3 | const User = { 4 | posts(parent, args, ctx, info) { 5 | return users.posts.filter((post) => { 6 | return post.author === parent.id 7 | }) 8 | }, 9 | comments(parent, args, ctx, info) { 10 | return users.comments.filter((comment) => { 11 | return comment.author === parent.id 12 | }) 13 | } 14 | } 15 | 16 | export default User; -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | datasource db { 5 | provider = "sqlite" 6 | url = env("DATABASE_URL") 7 | } 8 | 9 | generator client { 10 | provider = "prisma-client-js" 11 | } 12 | 13 | model Post { 14 | id Int @id @default(autoincrement()) 15 | title String 16 | content String 17 | published Boolean @default(false) 18 | createdAt DateTime @default(now()) 19 | } 20 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/Message.ts: -------------------------------------------------------------------------------- 1 | import { MessageResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface MessageParent { 5 | createdAt: string 6 | deliveredAt: string 7 | id: string 8 | readAt: string 9 | } 10 | 11 | export const Message: MessageResolvers.Type = { 12 | createdAt: parent => parent.createdAt, 13 | deliveredAt: parent => parent.deliveredAt, 14 | id: parent => parent.id, 15 | readAt: parent => parent.readAt, 16 | } 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/user/user.schema.ts: -------------------------------------------------------------------------------- 1 | // src/user/user.schema.ts 2 | import { Field, ObjectType } from '@nestjs/graphql'; 3 | import * as mongoose from 'mongoose'; 4 | import { Document } from 'mongoose'; 5 | 6 | export const UserSchema = new mongoose.Schema({ 7 | name: String, 8 | email: String, 9 | age: Number, 10 | }); 11 | 12 | @ObjectType() 13 | export class User extends Document { 14 | @Field() 15 | name: string; 16 | 17 | @Field() 18 | email: string; 19 | 20 | @Field() 21 | age: number; 22 | } 23 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagWhereInput } from './tag-where.input'; 4 | 5 | @InputType() 6 | export class TagListRelationFilter { 7 | @Field(() => TagWhereInput, { nullable: true }) 8 | every?: TagWhereInput; 9 | 10 | @Field(() => TagWhereInput, { nullable: true }) 11 | some?: TagWhereInput; 12 | 13 | @Field(() => TagWhereInput, { nullable: true }) 14 | none?: TagWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/update-many-tag.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { TagUpdateManyMutationInput } from './tag-update-many-mutation.input'; 4 | import { TagWhereInput } from './tag-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyTagArgs { 8 | @Field(() => TagUpdateManyMutationInput, { nullable: false }) 9 | data!: TagUpdateManyMutationInput; 10 | 11 | @Field(() => TagWhereInput, { nullable: true }) 12 | where?: TagWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": ["tslint:recommended"], 4 | "jsRules": { 5 | "no-unused-expression": true 6 | }, 7 | "rules": { 8 | "quotemark": [true, "single"], 9 | "member-access": [false], 10 | "ordered-imports": [false], 11 | "max-line-length": [true, 150], 12 | "member-ordering": [false], 13 | "interface-name": [false], 14 | "arrow-parens": false, 15 | "object-literal-sort-keys": false 16 | }, 17 | "rulesDirectory": [] 18 | } 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/schema.gql: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------ 2 | # THIS FILE WAS AUTOMATICALLY GENERATED (DO NOT MODIFY) 3 | # ------------------------------------------------------ 4 | 5 | type User { 6 | name: String! 7 | email: String! 8 | age: Float! 9 | } 10 | 11 | type Query { 12 | users: [User!]! 13 | } 14 | 15 | type Mutation { 16 | createUser(input: CreateUserInput!): User! 17 | } 18 | 19 | input CreateUserInput { 20 | name: String! 21 | email: String! 22 | age: Float! 23 | } 24 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "defaultSeverity": "error", 3 | "extends": ["tslint:recommended"], 4 | "jsRules": { 5 | "no-unused-expression": true 6 | }, 7 | "rules": { 8 | "quotemark": [true, "single"], 9 | "member-access": [false], 10 | "ordered-imports": [false], 11 | "max-line-length": [true, 150], 12 | "member-ordering": [false], 13 | "interface-name": [false], 14 | "arrow-parens": false, 15 | "object-literal-sort-keys": false 16 | }, 17 | "rulesDirectory": [] 18 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/update-many-user.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { UserUpdateManyMutationInput } from './user-update-many-mutation.input'; 4 | import { UserWhereInput } from './user-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyUserArgs { 8 | @Field(() => UserUpdateManyMutationInput, { nullable: false }) 9 | data!: UserUpdateManyMutationInput; 10 | 11 | @Field(() => UserWhereInput, { nullable: true }) 12 | where?: UserWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserWhereInput } from './user-where.input'; 4 | 5 | @InputType() 6 | export class UserListRelationFilter { 7 | @Field(() => UserWhereInput, { nullable: true }) 8 | every?: UserWhereInput; 9 | 10 | @Field(() => UserWhereInput, { nullable: true }) 11 | some?: UserWhereInput; 12 | 13 | @Field(() => UserWhereInput, { nullable: true }) 14 | none?: UserWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/.env: -------------------------------------------------------------------------------- 1 | # Environment variables declared in this file are automatically made available to Prisma. 2 | # See the documentation for more detail: https://pris.ly/d/prisma-schema#using-environment-variables 3 | 4 | # Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server (Preview) and MongoDB (Preview). 5 | # See the documentation for all the connection string options: https://pris.ly/d/connection-strings 6 | 7 | DATABASE_URL="postgres://api:development_pass@localhost:5434/example-api" -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/employee/dto/update-employee.input.ts: -------------------------------------------------------------------------------- 1 | import { CreateEmployeeInput } from './create-employee.input'; 2 | import { InputType, Field, Int, PartialType } from '@nestjs/graphql'; 3 | 4 | @InputType() 5 | export class UpdateEmployeeInput extends PartialType(CreateEmployeeInput) { 6 | @Field() 7 | id: number; 8 | @Field() 9 | firstname: string; 10 | 11 | @Field() 12 | lastname: string; 13 | 14 | @Field() 15 | designation: string; 16 | 17 | @Field({nullable:true}) 18 | city: string; 19 | } 20 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/database.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { Database } from './database'; 3 | 4 | describe('Database', () => { 5 | let provider: Database; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [Database], 10 | }).compile(); 11 | 12 | provider = module.get(Database); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(provider).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/update-one-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateInput } from './article-update.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneArticleArgs { 8 | @Field(() => ArticleUpdateInput, { nullable: false }) 9 | data!: ArticleUpdateInput; 10 | 11 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 12 | where!: ArticleWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/comment-update-many-mutation.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | @InputType() 4 | export class CommentUpdateManyMutationInput { 5 | @Field(() => String, { nullable: true }) 6 | commentId?: string; 7 | 8 | @Field(() => Date, { nullable: true }) 9 | createdAt?: Date | string; 10 | 11 | @Field(() => Date, { nullable: true }) 12 | updatedAt?: Date | string; 13 | 14 | @Field(() => String, { nullable: true }) 15 | body?: string; 16 | } 17 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/update-one-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentUpdateInput } from './comment-update.input'; 4 | import { CommentWhereUniqueInput } from './comment-where-unique.input'; 5 | 6 | @ArgsType() 7 | export class UpdateOneCommentArgs { 8 | @Field(() => CommentUpdateInput, { nullable: false }) 9 | data!: CommentUpdateInput; 10 | 11 | @Field(() => CommentWhereUniqueInput, { nullable: false }) 12 | where!: CommentWhereUniqueInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/items/dto/create-item.dto.ts: -------------------------------------------------------------------------------- 1 | import { ObjectType, Field, Int, ID } from '@nestjs/graphql'; 2 | import { IsString, IsNotEmpty, IsNumber } from 'class-validator'; 3 | @ObjectType() 4 | export class ItemType { 5 | @Field(() => ID) 6 | @IsString() 7 | readonly id?: string; 8 | @Field() 9 | @IsString() 10 | @IsNotEmpty() 11 | readonly title: string; 12 | @Field(() => Int) 13 | @IsNumber() 14 | readonly price: number; 15 | @Field() 16 | @IsString() 17 | readonly description: string; 18 | } 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/project/project.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from "@nestjs/common"; 2 | import { TypeOrmModule } from "@nestjs/typeorm"; 3 | import { Project } from "./entities/project.entity"; 4 | import { ProjectResolver } from "./project.resolver"; 5 | import { ProjectService } from "./project.service"; 6 | 7 | 8 | @Module({ 9 | imports: [ 10 | TypeOrmModule.forFeature([Project]) 11 | ], 12 | providers: [ 13 | ProjectResolver, ProjectService 14 | ] 15 | }) 16 | 17 | export class ProjectModule { 18 | 19 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # OS 14 | .DS_Store 15 | 16 | # Tests 17 | /coverage 18 | /.nyc_output 19 | 20 | # IDEs and editors 21 | /.idea 22 | .project 23 | .classpath 24 | .c9/ 25 | *.launch 26 | .settings/ 27 | *.sublime-workspace 28 | 29 | # IDE - VSCode 30 | .vscode/* 31 | !.vscode/settings.json 32 | !.vscode/tasks.json 33 | !.vscode/launch.json 34 | !.vscode/extensions.json -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/api/fragments/article.ts: -------------------------------------------------------------------------------- 1 | import { userFields } from './user'; 2 | 3 | export const articleFields = /* GraphQL */ ` 4 | fragment articleFields on Article { 5 | slug 6 | title 7 | description 8 | body 9 | tags { 10 | name 11 | } 12 | createdAt 13 | updatedAt 14 | favorited 15 | favoritesCount 16 | author { 17 | ...userFields 18 | following: isFollowing 19 | } 20 | } 21 | ${userFields} 22 | `; 23 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/api/pokemon/pokemon.graphql: -------------------------------------------------------------------------------- 1 | type Pokemon{ 2 | id: String! 3 | name:String! 4 | pokedex: String! 5 | type: String! 6 | league: League! 7 | } 8 | 9 | type Query{ 10 | pokemons: [Pokemon!] 11 | pokemon(id: ID): Pokemon! 12 | } 13 | 14 | type Deleted{ 15 | delete: Boolean! 16 | } 17 | 18 | type Mutation { 19 | create(name: String!, type: String!, pokedex: String!): Pokemon 20 | update(id: ID!, name: String!, type: String!, pokedex: String!): Pokemon 21 | delete(id: ID!): Deleted 22 | } 23 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/modules/domain/pokemon/pokemon.graphql: -------------------------------------------------------------------------------- 1 | type Pokemon { 2 | id: String! 3 | name:String! 4 | type: String! 5 | league: League 6 | } 7 | 8 | type Query { 9 | pokemons: [Pokemon!] 10 | pokemon(id: ID): Pokemon! 11 | } 12 | 13 | type Deleted { 14 | delete: Boolean! 15 | } 16 | 17 | type Mutation { 18 | create(name: String!, type: String!): Pokemon 19 | update(id: ID!, name: String!, type: String!): Pokemon 20 | delete(id: ID!): Deleted 21 | assign(id: ID!, leagueId: ID!): Pokemon 22 | } 23 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/Location.ts: -------------------------------------------------------------------------------- 1 | import { LocationResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface LocationParent { 5 | id: string 6 | lat: number 7 | lng: number 8 | address: string 9 | directions: string 10 | } 11 | 12 | export const Location: LocationResolvers.Type = { 13 | id: parent => parent.id, 14 | lat: parent => parent.lat, 15 | lng: parent => parent.lng, 16 | address: parent => parent.address, 17 | directions: parent => parent.directions, 18 | } 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # OS 14 | .DS_Store 15 | 16 | # Tests 17 | /coverage 18 | /.nyc_output 19 | 20 | # IDEs and editors 21 | /.idea 22 | .project 23 | .classpath 24 | .c9/ 25 | *.launch 26 | .settings/ 27 | *.sublime-workspace 28 | 29 | # IDE - VSCode 30 | .vscode/* 31 | !.vscode/settings.json 32 | !.vscode/tasks.json 33 | !.vscode/launch.json 34 | !.vscode/extensions.json -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/user/user.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { UserService } from './user.service'; 3 | 4 | describe('UserService', () => { 5 | let service: UserService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [UserService], 10 | }).compile(); 11 | 12 | service = module.get(UserService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleWhereInput } from './article-where.input'; 4 | 5 | @InputType() 6 | export class ArticleListRelationFilter { 7 | @Field(() => ArticleWhereInput, { nullable: true }) 8 | every?: ArticleWhereInput; 9 | 10 | @Field(() => ArticleWhereInput, { nullable: true }) 11 | some?: ArticleWhereInput; 12 | 13 | @Field(() => ArticleWhereInput, { nullable: true }) 14 | none?: ArticleWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/comment-list-relation-filter.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { CommentWhereInput } from './comment-where.input'; 4 | 5 | @InputType() 6 | export class CommentListRelationFilter { 7 | @Field(() => CommentWhereInput, { nullable: true }) 8 | every?: CommentWhereInput; 9 | 10 | @Field(() => CommentWhereInput, { nullable: true }) 11 | some?: CommentWhereInput; 12 | 13 | @Field(() => CommentWhereInput, { nullable: true }) 14 | none?: CommentWhereInput; 15 | } 16 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/project/project.graphql: -------------------------------------------------------------------------------- 1 | type Project { 2 | id: ID! 3 | name: String! 4 | description: String! 5 | createdAt: String! 6 | updatedAt: String! 7 | tasks: [Task]! 8 | } 9 | 10 | input NewProjectInput { 11 | name: String! 12 | description: String 13 | } 14 | 15 | input ProjectInput { 16 | name: String 17 | id: ID 18 | } 19 | 20 | type Query { 21 | project(input: ProjectInput!): Project! 22 | projects: [Project]! 23 | } 24 | 25 | type Mutation { 26 | newProject(input: NewProjectInput!): Project! 27 | } 28 | -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-code-first-mongoose-#03/src/items/items.module.ts: -------------------------------------------------------------------------------- 1 | import { MongooseModule } from '@nestjs/mongoose'; 2 | import { Module} from '@nestjs/common'; 3 | import { ItemSchema } from './items.schema'; 4 | import { ItemsResolver } from './items.resolver'; 5 | import { ItemsService } from './items.service'; 6 | 7 | @Module({ 8 | imports: [ 9 | MongooseModule.forFeature([{ 10 | name: 'Item', 11 | schema: ItemSchema 12 | }]), 13 | ], 14 | providers: [ 15 | ItemsService, ItemsResolver 16 | ] 17 | }) 18 | 19 | export class ItemsModule { 20 | 21 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/update-many-article.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateManyMutationInput } from './article-update-many-mutation.input'; 4 | import { ArticleWhereInput } from './article-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyArticleArgs { 8 | @Field(() => ArticleUpdateManyMutationInput, { nullable: false }) 9 | data!: ArticleUpdateManyMutationInput; 10 | 11 | @Field(() => ArticleWhereInput, { nullable: true }) 12 | where?: ArticleWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/comment/update-many-comment.args.ts: -------------------------------------------------------------------------------- 1 | import { ArgsType, Field } from '@nestjs/graphql'; 2 | 3 | import { CommentUpdateManyMutationInput } from './comment-update-many-mutation.input'; 4 | import { CommentWhereInput } from './comment-where.input'; 5 | 6 | @ArgsType() 7 | export class UpdateManyCommentArgs { 8 | @Field(() => CommentUpdateManyMutationInput, { nullable: false }) 9 | data!: CommentUpdateManyMutationInput; 10 | 11 | @Field(() => CommentWhereInput, { nullable: true }) 12 | where?: CommentWhereInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-update.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleUpdateManyWithoutTagsInput } from '../article/article-update-many-without-tags.input'; 4 | 5 | @InputType() 6 | export class TagUpdateInput { 7 | @Field(() => String, { nullable: true }) 8 | tagId?: string; 9 | 10 | @Field(() => String, { nullable: true }) 11 | name?: string; 12 | 13 | @Field(() => ArticleUpdateManyWithoutTagsInput, { nullable: true }) 14 | articles?: ArticleUpdateManyWithoutTagsInput; 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | .env 6 | 7 | # Logs 8 | logs 9 | *.log 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | lerna-debug.log* 14 | 15 | # OS 16 | .DS_Store 17 | 18 | # Tests 19 | /coverage 20 | /.nyc_output 21 | 22 | # IDEs and editors 23 | /.idea 24 | .project 25 | .classpath 26 | .c9/ 27 | *.launch 28 | .settings/ 29 | *.sublime-workspace 30 | 31 | # IDE - VSCode 32 | .vscode/* 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/entity/league.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, BaseEntity, OneToMany } from 'typeorm'; 2 | import { ObjectType } from 'type-graphql'; 3 | import { PokemonEntity } from './pokemon.entity'; 4 | 5 | @Entity('league') 6 | export class LeagueEntity extends BaseEntity { 7 | @PrimaryGeneratedColumn('uuid') id: string; 8 | 9 | @Column('varchar', { length: 500, unique: true }) 10 | name: string; 11 | 12 | @OneToMany(type => PokemonEntity, pokemon => pokemon.league) 13 | pokemons: PokemonEntity[]; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | pnpm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | 14 | # OS 15 | .DS_Store 16 | 17 | # Tests 18 | /coverage 19 | /.nyc_output 20 | 21 | # IDEs and editors 22 | /.idea 23 | .project 24 | .classpath 25 | .c9/ 26 | *.launch 27 | .settings/ 28 | *.sublime-workspace 29 | 30 | # IDE - VSCode 31 | .vscode/* 32 | !.vscode/settings.json 33 | !.vscode/tasks.json 34 | !.vscode/launch.json 35 | !.vscode/extensions.json -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-mongo-app/src/user/user.resolver.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { UserResolver } from './user.resolver'; 3 | 4 | describe('UserResolver', () => { 5 | let resolver: UserResolver; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [UserResolver], 10 | }).compile(); 11 | 12 | resolver = module.get(UserResolver); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(resolver).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-count.output.ts: -------------------------------------------------------------------------------- 1 | import { Field, Int, ObjectType } from '@nestjs/graphql'; 2 | 3 | @ObjectType() 4 | export class UserCount { 5 | @Field(() => Int, { nullable: false }) 6 | following!: number; 7 | 8 | @Field(() => Int, { nullable: false }) 9 | followers!: number; 10 | 11 | @Field(() => Int, { nullable: false }) 12 | favoriteArticles!: number; 13 | 14 | @Field(() => Int, { nullable: false }) 15 | articles!: number; 16 | 17 | @Field(() => Int, { nullable: false }) 18 | comments!: number; 19 | } 20 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | pnpm-debug.log* 10 | yarn-debug.log* 11 | yarn-error.log* 12 | lerna-debug.log* 13 | 14 | # OS 15 | .DS_Store 16 | 17 | # Tests 18 | /coverage 19 | /.nyc_output 20 | 21 | # IDEs and editors 22 | /.idea 23 | .project 24 | .classpath 25 | .c9/ 26 | *.launch 27 | .settings/ 28 | *.sublime-workspace 29 | 30 | # IDE - VSCode 31 | .vscode/* 32 | !.vscode/settings.json 33 | !.vscode/tasks.json 34 | !.vscode/launch.json 35 | !.vscode/extensions.json -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-typeorm/src/modules/config/config.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@nestjs/common'; 2 | import * as dotenv from 'dotenv'; 3 | import * as fs from 'fs'; 4 | 5 | @Injectable() 6 | export class ConfigService { 7 | private readonly envConfig: { [key: string]: string }; 8 | 9 | constructor(filePath: string) { 10 | this.envConfig = dotenv.parse(fs.readFileSync(filePath)); 11 | } 12 | 13 | get(key: string): string { 14 | return this.envConfig[key]; 15 | } 16 | 17 | isEnv(env: string) { 18 | return this.envConfig.APP_ENV === env; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/src/resolvers/index.js: -------------------------------------------------------------------------------- 1 | import { extractFragmentReplacements } from 'prisma-binding' 2 | import Query from './Query' 3 | import Mutation from './Mutation' 4 | import Subscription from './Subscription' 5 | import User from './User' 6 | import Post from './Post' 7 | import Comment from './Comment' 8 | 9 | const resolvers = { 10 | Query, 11 | Mutation, 12 | Subscription, 13 | User, 14 | Post, 15 | Comment 16 | } 17 | 18 | const fragmentReplacements = extractFragmentReplacements(resolvers) 19 | 20 | export { resolvers, fragmentReplacements } -------------------------------------------------------------------------------- /Grapql using Yoga Gql/graphql-yoga-with-typeorm/src/utils/decodeJWT.ts: -------------------------------------------------------------------------------- 1 | import jwt from "jsonwebtoken"; 2 | import User from "../entities/User"; 3 | 4 | const decodeJWT = async (token: string): Promise => { 5 | try { 6 | const decodedToken: any = jwt.verify(token, process.env.JWT_SECRET || ""); 7 | const { id } = decodedToken; 8 | const user = await User.findOne({ id }); 9 | if (user) { 10 | return user; 11 | } else { 12 | return undefined; 13 | } 14 | } catch (error) { 15 | return undefined; 16 | } 17 | }; 18 | 19 | export default decodeJWT; 20 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-mongo/src/resolvers/authorization.js: -------------------------------------------------------------------------------- 1 | import {skip, combineResolvers} from 'graphql-resolvers'; 2 | import { ForbiddenError } from 'apollo-server'; 3 | 4 | 5 | export const isAuthenticated = (parent, args, {me}) => { 6 | if(me){ 7 | return skip; 8 | } 9 | return new ForbiddenError('user is not authenticated'); 10 | } 11 | 12 | export const isAdmin = combineResolvers( 13 | isAuthenticated, 14 | (parent, args , { me : {role}}) => { 15 | return role === 'admin' ? skip : new ForbiddenError('user is not authz for this operation'); 16 | } 17 | ); -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # OS 14 | .DS_Store 15 | 16 | # Tests 17 | /coverage 18 | /.nyc_output 19 | 20 | # IDEs and editors 21 | /.idea 22 | .project 23 | .classpath 24 | .c9/ 25 | *.launch 26 | .settings/ 27 | *.sublime-workspace 28 | 29 | # IDE - VSCode 30 | .vscode/* 31 | !.vscode/settings.json 32 | !.vscode/tasks.json 33 | !.vscode/launch.json 34 | !.vscode/extensions.json 35 | 36 | #guide 37 | 38 | /article -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/modules/domain/entity/league.entity.ts: -------------------------------------------------------------------------------- 1 | import { Entity, PrimaryGeneratedColumn, Column, BaseEntity, OneToMany } from 'typeorm'; 2 | import { ObjectType } from 'type-graphql'; 3 | import { PokemonEntity } from './pokemon.entity'; 4 | 5 | @Entity('league') 6 | export class LeagueEntity extends BaseEntity { 7 | @PrimaryGeneratedColumn('uuid') id: string; 8 | 9 | @Column('varchar', { length: 500, unique: true }) 10 | name: string; 11 | 12 | @OneToMany(type => PokemonEntity, pokemon => pokemon.league) 13 | pokemons: PokemonEntity[]; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/custom-types-02/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-basics", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon src/index.js --exec babel-node", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "babel-cli": "^6.26.0", 14 | "babel-preset-env": "^1.7.0", 15 | "graphql-yoga": "^1.14.10" 16 | }, 17 | "devDependencies": { 18 | "nodemon": "^1.17.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Graphql using Apollo/express-graphql-apollo-sequelize/src/resolvers/authorization.js: -------------------------------------------------------------------------------- 1 | import {skip, combineResolvers} from 'graphql-resolvers'; 2 | import { ForbiddenError } from 'apollo-server'; 3 | 4 | 5 | export const isAuthenticated = (parent, args, {me}) => { 6 | if(me){ 7 | return skip; 8 | } 9 | return new ForbiddenError('user is not authenticated'); 10 | } 11 | 12 | export const isAdmin = combineResolvers( 13 | isAuthenticated, 14 | (parent, args , { me : {role}}) => { 15 | return role === 'admin' ? skip : new ForbiddenError('user is not authz for this operation'); 16 | } 17 | ); -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-scalar-field.enum.ts: -------------------------------------------------------------------------------- 1 | import { registerEnumType } from '@nestjs/graphql'; 2 | 3 | export enum ArticleScalarFieldEnum { 4 | articleId = 'articleId', 5 | slug = 'slug', 6 | title = 'title', 7 | description = 'description', 8 | body = 'body', 9 | createdAt = 'createdAt', 10 | updatedAt = 'updatedAt', 11 | favoritesCount = 'favoritesCount', 12 | authorId = 'authorId', 13 | } 14 | 15 | registerEnumType(ArticleScalarFieldEnum, { 16 | name: 'ArticleScalarFieldEnum', 17 | description: undefined, 18 | }); 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/app_modules/nestjs-authorization-token/index.ts: -------------------------------------------------------------------------------- 1 | import { createParamDecorator, ExecutionContext } from '@nestjs/common'; 2 | import { IncomingMessage } from 'http'; 3 | 4 | // tslint:disable-next-line:variable-name 5 | export const AuthorizationToken = createParamDecorator( 6 | (data: unknown, context: ExecutionContext) => { 7 | const request = context.switchToHttp().getRequest(); 8 | const authorization = request.headers.authorization; 9 | const [, token] = String(authorization).split(' '); 10 | return token; 11 | }, 12 | ); 13 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/database/models/Comment.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | const Schema = mongoose.Schema; 3 | import { ObjectID } from "mongodb"; 4 | 5 | ObjectID.prototype.valueOf = function() { 6 | return this.toString(); 7 | }; 8 | 9 | const CommentSchema = new Schema({ 10 | text: { 11 | type: String, 12 | required: true 13 | }, 14 | author: { 15 | type: Schema.Types.ObjectId, 16 | ref: "User" 17 | }, 18 | post: { 19 | type: Schema.Types.ObjectId, 20 | ref: "Post" 21 | } 22 | }) 23 | 24 | export default mongoose.model('Comment', CommentSchema) -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-client/src/graphql/mutations.js: -------------------------------------------------------------------------------- 1 | import { gql } from '@apollo/client'; 2 | 3 | export const CREATE_POST_MUTATION = gql` 4 | mutation createPost( 5 | $title: String! 6 | $body: String! 7 | $published: Boolean! 8 | $authorId: ID! 9 | ) { 10 | createPost( 11 | data: { 12 | title: $title 13 | body: $body 14 | published: $published 15 | author: $authorId 16 | } 17 | ) { 18 | title 19 | body 20 | author { 21 | name 22 | } 23 | published 24 | } 25 | } 26 | `; 27 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/relational-basics-03/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-basics", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon src/index.js --exec babel-node", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "babel-cli": "^6.26.0", 14 | "babel-preset-env": "^1.7.0", 15 | "graphql-yoga": "^1.14.10" 16 | }, 17 | "devDependencies": { 18 | "nodemon": "^1.17.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-example/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | package-lock.json 13 | yarn.lock 14 | 15 | # OS 16 | .DS_Store 17 | 18 | # Tests 19 | /coverage 20 | /.nyc_output 21 | 22 | # IDEs and editors 23 | /.idea 24 | .project 25 | .classpath 26 | .c9/ 27 | *.launch 28 | .settings/ 29 | *.sublime-workspace 30 | 31 | # IDE - VSCode 32 | .vscode/* 33 | !.vscode/settings.json 34 | !.vscode/tasks.json 35 | !.vscode/launch.json 36 | !.vscode/extensions.json 37 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-create.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateNestedManyWithoutTagsInput } from '../article/article-create-nested-many-without-tags.input'; 4 | 5 | @InputType() 6 | export class TagCreateInput { 7 | @Field(() => String, { nullable: true }) 8 | tagId?: string; 9 | 10 | @Field(() => String, { nullable: false }) 11 | name!: string; 12 | 13 | @Field(() => ArticleCreateNestedManyWithoutTagsInput, { nullable: true }) 14 | articles?: ArticleCreateNestedManyWithoutTagsInput; 15 | } 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/src/modules/domain/pokemon/pokemon.module.ts: -------------------------------------------------------------------------------- 1 | import { Module } from '@nestjs/common'; 2 | import { PokemonService } from './pokemon.service'; 3 | import { TypeOrmModule } from '@nestjs/typeorm'; 4 | import { PokemonResolver } from './pokemon.resolver'; 5 | import { PokemonEntity } from '../entity/pokemon.entity'; 6 | import { LeagueEntity } from '../entity/league.entity'; 7 | 8 | 9 | @Module({ 10 | imports: [TypeOrmModule.forFeature([PokemonEntity, LeagueEntity])], 11 | providers: [PokemonService, PokemonResolver], 12 | }) 13 | export class PokemonModule { 14 | } 15 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/resolvers/ExperienceCategory.ts: -------------------------------------------------------------------------------- 1 | import { ExperienceCategoryResolvers } from '../generated/resolvers' 2 | import { TypeMap } from './types/TypeMap' 3 | 4 | export interface ExperienceCategoryParent { 5 | id: string 6 | mainColor: string 7 | name: string 8 | } 9 | 10 | export const ExperienceCategory: ExperienceCategoryResolvers.Type = { 11 | id: parent => parent.id, 12 | mainColor: parent => parent.mainColor, 13 | name: parent => parent.name, 14 | experience: (parent, args, ctx) => ctx.db.experienceCategory({ id: parent.id }).experience(), 15 | } 16 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-apis-comments-04/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-basics", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon src/index.js --exec babel-node", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "babel-cli": "^6.26.0", 14 | "babel-preset-env": "^1.7.0", 15 | "graphql-yoga": "^1.14.10" 16 | }, 17 | "devDependencies": { 18 | "nodemon": "^1.17.5" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-mongodb/graphql/index.js: -------------------------------------------------------------------------------- 1 | import {mergeResolvers, mergeTypeDefs} from '@graphql-tools/merge'; 2 | 3 | import User from './types/user'; 4 | import Post from './types/post' 5 | import Comment from './types/comment' 6 | 7 | import UserResolver from './resolvers/user'; 8 | import PostResolver from './resolvers/post' 9 | import CommentResolver from './resolvers/comment' 10 | 11 | const RootTypeDef = mergeTypeDefs([User, Post, Comment], {all: true}) 12 | const RootResolver = mergeResolvers([UserResolver, PostResolver, CommentResolver]); 13 | 14 | export { RootTypeDef, RootResolver}; 15 | 16 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/index.ts: -------------------------------------------------------------------------------- 1 | import { GraphQLServer } from 'graphql-yoga' 2 | import { Prisma } from './generated/prisma-client' 3 | import { resolvers } from './resolvers' 4 | 5 | const db = new Prisma({ 6 | endpoint: process.env.PRISMA_ENDPOINT!, 7 | secret: process.env.PRISMA_SECRET!, 8 | debug: true, 9 | }) 10 | 11 | const server = new GraphQLServer({ 12 | typeDefs: './src/schema.graphql', 13 | resolvers: resolvers as any, 14 | context: req => ({ ...req, db }), 15 | }) 16 | 17 | server.start(({ port }) => 18 | console.log(`Server is running on http://localhost:${port}`), 19 | ) 20 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-update-many-with-where-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagScalarWhereInput } from './tag-scalar-where.input'; 4 | import { TagUpdateManyMutationInput } from './tag-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class TagUpdateManyWithWhereWithoutArticlesInput { 8 | @Field(() => TagScalarWhereInput, { nullable: false }) 9 | where!: TagScalarWhereInput; 10 | 11 | @Field(() => TagUpdateManyMutationInput, { nullable: false }) 12 | data!: TagUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag.model.ts: -------------------------------------------------------------------------------- 1 | import { Field, ID, ObjectType } from '@nestjs/graphql'; 2 | 3 | import { Article } from '../article/article.model'; 4 | import { TagCount } from './tag-count.output'; 5 | 6 | @ObjectType() 7 | export class Tag { 8 | @Field(() => ID, { nullable: false }) 9 | tagId!: string; 10 | 11 | @Field(() => String, { nullable: false }) 12 | name!: string; 13 | 14 | @Field(() => [Article], { nullable: true }) 15 | articles?: Array
; 16 | 17 | @Field(() => TagCount, { nullable: true }) 18 | _count?: TagCount | null; 19 | } 20 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-schema-first-#04/.gitignore: -------------------------------------------------------------------------------- 1 | # compiled output 2 | /dist 3 | /node_modules 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # OS 14 | .DS_Store 15 | 16 | # Tests 17 | /coverage 18 | /.nyc_output 19 | 20 | # IDEs and editors 21 | /.idea 22 | .project 23 | .classpath 24 | .c9/ 25 | *.launch 26 | .settings/ 27 | *.sublime-workspace 28 | 29 | # IDE - VSCode 30 | .vscode/* 31 | !.vscode/settings.json 32 | !.vscode/tasks.json 33 | !.vscode/launch.json 34 | !.vscode/extensions.json 35 | 36 | #guide 37 | 38 | /article -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/database/models/Comment.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | const Schema = mongoose.Schema; 3 | import { ObjectID } from "mongodb"; 4 | 5 | ObjectID.prototype.valueOf = function() { 6 | return this.toString(); 7 | }; 8 | 9 | const CommentSchema = new Schema({ 10 | text: { 11 | type: String, 12 | required: true 13 | }, 14 | author: { 15 | type: Schema.Types.ObjectId, 16 | ref: "User" 17 | }, 18 | post: { 19 | type: Schema.Types.ObjectId, 20 | ref: "Post" 21 | } 22 | }) 23 | 24 | export default mongoose.model('Comment', CommentSchema) -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-create-or-connect-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagCreateWithoutArticlesInput } from './tag-create-without-articles.input'; 4 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 5 | 6 | @InputType() 7 | export class TagCreateOrConnectWithoutArticlesInput { 8 | @Field(() => TagWhereUniqueInput, { nullable: false }) 9 | where!: TagWhereUniqueInput; 10 | 11 | @Field(() => TagCreateWithoutArticlesInput, { nullable: false }) 12 | create!: TagCreateWithoutArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-mongodb/graphql/index.js: -------------------------------------------------------------------------------- 1 | import {mergeResolvers, mergeTypeDefs} from '@graphql-tools/merge'; 2 | 3 | import User from './types/user'; 4 | import Post from './types/post' 5 | import Comment from './types/comment' 6 | 7 | import UserResolver from './resolvers/user'; 8 | import PostResolver from './resolvers/post' 9 | import CommentResolver from './resolvers/comment' 10 | 11 | const RootTypeDef = mergeTypeDefs([User, Post, Comment], {all: true}) 12 | const RootResolver = mergeResolvers([UserResolver, PostResolver, CommentResolver]); 13 | 14 | export { RootTypeDef, RootResolver}; 15 | 16 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/category/category.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { CategoryService } from './category.service'; 3 | 4 | describe('CategoryService', () => { 5 | let service: CategoryService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [CategoryService], 10 | }).compile(); 11 | 12 | service = module.get(CategoryService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/src/domain/employee/employee.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { Test, TestingModule } from '@nestjs/testing'; 2 | import { EmployeeService } from './employee.service'; 3 | 4 | describe('EmployeeService', () => { 5 | let service: EmployeeService; 6 | 7 | beforeEach(async () => { 8 | const module: TestingModule = await Test.createTestingModule({ 9 | providers: [EmployeeService], 10 | }).compile(); 11 | 12 | service = module.get(EmployeeService); 13 | }); 14 | 15 | it('should be defined', () => { 16 | expect(service).toBeDefined(); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/advance-series/src/api/index.js: -------------------------------------------------------------------------------- 1 | const project = require('./project') 2 | const loaders = require('./loaders') 3 | const task = require('./task') 4 | const search = require('./search') 5 | const merge = require('lodash/merge') 6 | 7 | module.exports = { 8 | typeDefs: [ 9 | project.typeDefs, 10 | task.typeDefs, 11 | search.typeDefs 12 | ].join(' '), 13 | resolvers: merge({}, project.resolvers, task.resolvers, search.resolvers), 14 | context: { 15 | models: { 16 | project: project.model, 17 | task: task.model 18 | }, 19 | loaders: loaders() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/graphql-starter-series/graphql-mutations-05/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "graphql-basics", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon src/index.js --exec babel-node", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "babel-cli": "^6.26.0", 14 | "babel-preset-env": "^1.7.0", 15 | "graphql-yoga": "^1.14.10", 16 | "uuid": "^3.3.2" 17 | }, 18 | "devDependencies": { 19 | "nodemon": "^1.17.5" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga/hello-world/src/resolvers/Mutation.js: -------------------------------------------------------------------------------- 1 | const Mutation = { 2 | createUser(parent, args, { DB }, info) { 3 | const { email } = args.data; 4 | const emailTaken = DB.users.some(user => user.email === email); 5 | if(emailTaken) { 6 | throw new Error('Email already taken...') 7 | } 8 | }, 9 | updateUser(parent, args, { DB }, info) { 10 | const { email } = args.data; 11 | const emailTaken = DB.users.some(user => user.email === email); 12 | if(emailTaken) { 13 | throw new Error('Email already taken...') 14 | } 15 | } 16 | } 17 | 18 | export default Mutation; -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-code-first-#02/.dockerignore: -------------------------------------------------------------------------------- 1 | # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. 2 | 3 | # Git 4 | .git 5 | 6 | # Caches 7 | .cache 8 | 9 | # Packages 10 | node_modules 11 | 12 | # Logs 13 | *.log 14 | 15 | # Temporary and built assets 16 | tmp 17 | dist 18 | 19 | # Local development 20 | docker-compose.override.yml 21 | docker-compose.override.dist.yml 22 | 23 | # IDEs and editors 24 | /.idea 25 | .project 26 | .classpath 27 | .c9/ 28 | *.launch 29 | .settings/ 30 | *.sublime-workspace 31 | .vscode 32 | 33 | # System Files 34 | .DS_Store 35 | Thumbs.db -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/tag/tag-update-with-where-unique-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { TagUpdateWithoutArticlesInput } from './tag-update-without-articles.input'; 4 | import { TagWhereUniqueInput } from './tag-where-unique.input'; 5 | 6 | @InputType() 7 | export class TagUpdateWithWhereUniqueWithoutArticlesInput { 8 | @Field(() => TagWhereUniqueInput, { nullable: false }) 9 | where!: TagWhereUniqueInput; 10 | 11 | @Field(() => TagUpdateWithoutArticlesInput, { nullable: false }) 12 | data!: TagUpdateWithoutArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-create-or-connect-without-articles.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutArticlesInput } from './user-create-without-articles.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutArticlesInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutArticlesInput, { nullable: false }) 12 | create!: UserCreateWithoutArticlesInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-create-or-connect-without-comments.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutCommentsInput } from './user-create-without-comments.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutCommentsInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutCommentsInput, { nullable: false }) 12 | create!: UserCreateWithoutCommentsInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-update-many-with-where-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserScalarWhereInput } from './user-scalar-where.input'; 4 | import { UserUpdateManyMutationInput } from './user-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class UserUpdateManyWithWhereWithoutFollowersInput { 8 | @Field(() => UserScalarWhereInput, { nullable: false }) 9 | where!: UserScalarWhereInput; 10 | 11 | @Field(() => UserUpdateManyMutationInput, { nullable: false }) 12 | data!: UserUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-update-many-with-where-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserScalarWhereInput } from './user-scalar-where.input'; 4 | import { UserUpdateManyMutationInput } from './user-update-many-mutation.input'; 5 | 6 | @InputType() 7 | export class UserUpdateManyWithWhereWithoutFollowingInput { 8 | @Field(() => UserScalarWhereInput, { nullable: false }) 9 | where!: UserScalarWhereInput; 10 | 11 | @Field(() => UserUpdateManyMutationInput, { nullable: false }) 12 | data!: UserUpdateManyMutationInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-schema-first-#01/.dockerignore: -------------------------------------------------------------------------------- 1 | # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. 2 | 3 | # Git 4 | .git 5 | 6 | # Caches 7 | .cache 8 | 9 | # Packages 10 | node_modules 11 | 12 | # Logs 13 | *.log 14 | 15 | # Temporary and built assets 16 | tmp 17 | dist 18 | 19 | # Local development 20 | docker-compose.override.yml 21 | docker-compose.override.dist.yml 22 | 23 | # IDEs and editors 24 | /.idea 25 | .project 26 | .classpath 27 | .c9/ 28 | *.launch 29 | .settings/ 30 | *.sublime-workspace 31 | .vscode 32 | 33 | # System Files 34 | .DS_Store 35 | Thumbs.db -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/src/utils/getUserId.js: -------------------------------------------------------------------------------- 1 | import jwt from 'jsonwebtoken' 2 | 3 | const getUserId = (request, requireAuth = true) => { 4 | const header = request.request ? request.request.headers.authorization : request.connection.context.Authorization 5 | 6 | if (header) { 7 | const token = header.replace('Bearer ', '') 8 | const decoded = jwt.verify(token, 'thisisasecret') 9 | return decoded.userId 10 | } 11 | 12 | if (requireAuth) { 13 | throw new Error('Authentication required') 14 | } 15 | 16 | return null 17 | } 18 | 19 | export { getUserId as default } -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/article/article-create-or-connect-without-tags.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { ArticleCreateWithoutTagsInput } from './article-create-without-tags.input'; 4 | import { ArticleWhereUniqueInput } from './article-where-unique.input'; 5 | 6 | @InputType() 7 | export class ArticleCreateOrConnectWithoutTagsInput { 8 | @Field(() => ArticleWhereUniqueInput, { nullable: false }) 9 | where!: ArticleWhereUniqueInput; 10 | 11 | @Field(() => ArticleCreateWithoutTagsInput, { nullable: false }) 12 | create!: ArticleCreateWithoutTagsInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-create-or-connect-without-followers.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFollowersInput } from './user-create-without-followers.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutFollowersInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutFollowersInput, { nullable: false }) 12 | create!: UserCreateWithoutFollowersInput; 13 | } 14 | -------------------------------------------------------------------------------- /Graphql using Apollo/nestjs-graphql-prisma-app/src/@generated/user/user-create-or-connect-without-following.input.ts: -------------------------------------------------------------------------------- 1 | import { Field, InputType } from '@nestjs/graphql'; 2 | 3 | import { UserCreateWithoutFollowingInput } from './user-create-without-following.input'; 4 | import { UserWhereUniqueInput } from './user-where-unique.input'; 5 | 6 | @InputType() 7 | export class UserCreateOrConnectWithoutFollowingInput { 8 | @Field(() => UserWhereUniqueInput, { nullable: false }) 9 | where!: UserWhereUniqueInput; 10 | 11 | @Field(() => UserCreateWithoutFollowingInput, { nullable: false }) 12 | create!: UserCreateWithoutFollowingInput; 13 | } 14 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-prisma/src/utils.ts: -------------------------------------------------------------------------------- 1 | import * as jwt from 'jsonwebtoken' 2 | 3 | interface Context { 4 | request: any 5 | } 6 | 7 | export function getUserId(context: Context) { 8 | const Authorization = context.request.get('Authorization') 9 | if (Authorization) { 10 | const token = Authorization.replace('Bearer ', '') 11 | const { userId } = jwt.verify(token, process.env.APP_SECRET!) as { 12 | userId: string 13 | } 14 | return userId 15 | } 16 | 17 | throw new AuthError() 18 | } 19 | 20 | export class AuthError extends Error { 21 | constructor() { 22 | super('Not authorized') 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Grapql using Yoga Gql/express-graphql-yoga-prisma/prisma-review-website/datamodel.graphql: -------------------------------------------------------------------------------- 1 | type Book { 2 | id: ID! @unique 3 | title: String! 4 | author: String! 5 | isbn: String! 6 | reviews: [Review!]! @relation(name: "ReviewToBook", onDelete: CASCADE) 7 | } 8 | 9 | type User { 10 | id: ID! @unique 11 | username: String! @unique 12 | reviews: [Review!]! @relation(name: "ReviewToUser", onDelete: CASCADE) 13 | } 14 | 15 | type Review { 16 | id: ID! @unique 17 | text: String 18 | rating: Int! 19 | book: Book! @relation(name:"ReviewToBook", onDelete: SET_NULL) 20 | author: User! @relation(name:"ReviewToUser", onDelete: SET_NULL) 21 | } -------------------------------------------------------------------------------- /Graphql using Apollo/nest-graphql-prisma/src/posts/schema.graphql: -------------------------------------------------------------------------------- 1 | type Post { 2 | id: ID! 3 | title: String! 4 | content: String! 5 | published: Boolean! 6 | createdAt: String! 7 | } 8 | 9 | input NewPost { 10 | title: String! 11 | content: String! 12 | } 13 | 14 | input UpdatePost { 15 | id:ID! 16 | published: Boolean 17 | title: String 18 | content: String 19 | } 20 | 21 | type Query { 22 | posts: [Post!]! 23 | post(id: ID!): Post 24 | } 25 | 26 | type Mutation { 27 | createPost(input: NewPost): Post! 28 | updatePost(input: UpdatePost): Post 29 | deletePost(id: ID!): Post 30 | } --------------------------------------------------------------------------------