GithubHelp home page GithubHelp logo

endykaufman / typegraphql-prisma-nestjs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michallytek/type-graphql

22.0 22.0 9.0 256.44 MB

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!

Home Page: https://typegraphql.ml/

License: MIT License

TypeScript 96.97% JavaScript 2.08% Shell 0.10% CSS 0.85%

typegraphql-prisma-nestjs's People

Contributors

0xflotus avatar ahabhgk avatar beeman avatar christiandavis avatar endykaufman avatar jmfury avatar michallytek avatar samuelnittala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

typegraphql-prisma-nestjs's Issues

Following the discussion on https://github.com/MichalLytek/type-graphql/issues/476#issuecomment-594386507

@EndyKaufman
Thank you for your help.

Eventually I was able to inject the primsa client to the context using this method:

GraphQLModule.forRootAsync({
      useFactory: async (configService: ConfigService) => ({
        autoSchemaFile:
          configService.get('GRAPHQL_SCHEMA_DEST') || './src/schema.graphql',
        debug: configService.get('GRAPHQL_DEBUG') === '1' ? true : false,
        playground:
          configService.get('PLAYGROUND_ENABLE') === '1' ? true : false,
        context: ({ req, prisma }) => ({ req, prisma: new PrismaClient() })
      }),

Update to NestJS 7.0

NestJS decided to reimplement all the features from scratch in type-graphql but using the same API meaning that every type-graphql import needs to be changed to @nestjs/graphql and the unimplemented decorators like FieldResolver and Arg need to be removed from the imports

Source: https://docs.nestjs.com/migration-guide#graphql

GraphQL#
In the version 6 major release of NestJS, we introduced the code-first approach as a compatibility layer between the type-graphql package and the @nestjs/graphql module. Eventually, our team decided to reimplement all the features from scratch due to a lack of flexibility. To avoid numerous breaking changes, the public API is backward-compatible and may resemble type-graphql.

In order to migrate your existing application, simply rename all the type-graphql imports to the @nestjs/graphql.

⚠️ Greenkeeper is no longer available for new installations

Hello!

Greenkeeper is no longer available for new installations.

The service will be saying goodbye πŸ‘‹ and passing the torch to Snyk on June 3rd, 2020. Find out more at greenkeeper.io.

If this is your only Greenkeeper installation, you can just sign up for Snyk directly, it’s free for Open Source and even has free features for private projects as well.

Nevertheless, thanks for your interest in Greenkeeper! We’re sure your repositories will find a good home at Snyk β˜€οΈπŸ‘πŸ’œ

All the best from everyone at Greenkeeper! πŸ‘‹πŸ€–πŸŒ΄

Documentation

Are there specific areas of this fork that differ with MichalLytek/type-graphql? Are there any plans to include the differences in the documentation?

Support

What level of support will this fork have? Can I rely on it being relatively up to date with MichalLytek/type-graphql, or is this just an experiment that may be abandoned in the near future?

Generated Crud function names overlap

Its seems there is an issue with the generated crud opterations.

I have cloned your example project and tried adding the Recipes and Ingeredients to the prisma schema and removing the coded ./src/recipes/recipes.module.ts from the AppModule.

//  ./prisma/schema.prisma
model Recipes {
  id          Int       @default(autoincrement())
  title  String    @unique
  description String?   
  creationDate DateTime  @default(now()) @map("date_created")
  ingredients Ingredient[]
  @@map("recipies")
}

model Ingredient {
  id Int @unique @default(autoincrement())
  name String
  @@map("ingredient")
}

When I did this and attemted to regenerat the dal folder I ran into the following issue

src/dal/resolvers/crud/Recipes/RecipesCrudResolver.ts:19:9 - error TS2393: Duplicate function implementation.

19   async recipes(@Context() ctx: any, @Args() args: FindOneRecipesArgs): Promise<Recipes | null> {
           ~~~~~~~
src/dal/resolvers/crud/Recipes/RecipesCrudResolver.ts:27:9 - error TS2393: Duplicate function implementation.

27   async recipes(@Context() ctx: any, @Args() args: FindManyRecipesArgs): Promise<Recipes[]> {
           ~~~~~~~

Found 2 error(s).

error Command failed with exit code 1.

I looked into the generated crud operations and I found it had used the same name for the get one and get many functions

//  ./src/dal/resolvers/crud/Recipes/RecipesCrudResolver.ts
  @Query(_returns => Recipes, {
    nullable: true,
    description: undefined
  })
  async recipes(@Context() ctx: any, @Args() args: FindOneRecipesArgs): Promise<Recipes | null> {
    return ctx.prisma.recipes.findOne(args);
  }

  @Query(_returns => [Recipes], {
    nullable: false,
    description: undefined
  })
  async recipes(@Context() ctx: any, @Args() args: FindManyRecipesArgs): Promise<Recipes[]> {
    return ctx.prisma.recipes.findMany(args);
  }

After renaming my table in the schema.prisma file to Recipe the generated code worked fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.