MichalLytek / type-graphql

Create GraphQL schema and resolvers with TypeScript, using classes and decorators!
https://typegraphql.com
MIT License
8.04k stars 678 forks source link

Towards release 1.0 #623

Closed MichalLytek closed 4 years ago

MichalLytek commented 4 years ago

Today, I released the first Release Candidate version of major 1.0.0 πŸŽ‰ https://www.npmjs.com/package/type-graphql/v/1.0.0-rc.1 It is also distributed as a new major version on the default latest tag.

This release contains a lot of breaking changes, so please read the release notes carefully πŸ‘€ https://github.com/MichalLytek/type-graphql/releases/tag/v1.0.0-rc.1

The 1.0.0 milestone is finished in 97% - it contains of 87 closed issues! 😡 https://github.com/MichalLytek/type-graphql/milestone/3 The work that has to be also done before final release is to write the announcement post about the 1.0.0 release, after 2 years of developing TypeGraphQL ☺️

Feel free to update your apps and let me know how the new version works for you and what improvements you would like to see in the upcoming 1.0.0 release!

And don't forget to support the project as its ongoing development is possible only thanks to the support by the community ❀️

Especially if you are using it commercially - just to ensure that the project which your product relies on is actively maintained and improved πŸ’ͺ

adamovittorio commented 4 years ago

Hello @MichalLytek, Thanks for your fantastic work and congrats on the release! I've updated from type-graphql@beta to the new 1.0.0-rc.1, and I'm trying to use the new schema directive support to make my federated service works. Is it possible to include some examples or update the previous one, on how to build a federated schema?

MichalLytek commented 4 years ago

@adamovittorio Have you checked this example? https://github.com/MichalLytek/type-graphql/tree/master/examples/apollo-federation

ujwal-setlur commented 4 years ago

@MichalLytek I upgraded, and everything worked just fine for me. I had been on the 0.18 beta releases. Great work!

I guess graphql-15.0.0 is now supported? I thought that was some ways off...good to see!

smolinari commented 4 years ago

Awesome stuff! Keep up the great work!

Scott

jeromemeichelbeck commented 4 years ago

Awesome, will try it on my current project!

MichalLytek commented 4 years ago

Yesterday, v1.0.0-rc.2 has been released πŸš€ It contains 2 last-minute fixes but also 2 small features: https://github.com/MichalLytek/type-graphql/releases/tag/v1.0.0-rc.2

Please give the v1.0.0 RC release a try and feel free to report some bugs or lacking important features - this way we can improve the things before final 1.0 release πŸ˜‰

rchl commented 4 years ago

Not sure if you are interested in that kind of feedback but I'm using type-graphql together with other dependencies in a Nuxt project and I can't update to new version due to various dependencies still relying on graphql v14. So, unfortunately, I can't provide any feedback on the new version.

MichalLytek commented 4 years ago

@rchl graphql-js v15 breaking changes should not affect 99% of apps/libraries, even apollo ecosystem support v15 via the wide deps range: https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-core/package.json#L50-L52

So technically, you could even ignore the TypeGraphQL peer deps requirement and use it with v14 - the only affected code is the import path import { Options as GraphQLPrintSchemaOptions } from "graphql/utilities/printSchema"; which is removed from runtime JS code, so skipLibCheck: true should prevent compilation failures πŸ˜‰

rchl commented 4 years ago

This is what I get when I try to use it with graphql v14:

FATAL: Looks like you use an incorrect version of the 'graphql' package: "14.6.0". Please ensure that you have installed a version that meets TypeGraphQL's requirement: "^15.0.0".

  at Object.ensureInstalledCorrectGraphQLPackage (node_modules/type-graphql/dist/utils/graphql-version.js:19:15)
  at Function.checkForErrors (node_modules/type-graphql/dist/schema/schema-generator.js:42:27)
  at Function.generateFromMetadataSync (node_modules/type-graphql/dist/schema/schema-generator.js:25:14)
  at Function.generateFromMetadata (node_modules/type-graphql/dist/schema/schema-generator.js:15:29)
  at Object.buildSchema (node_modules/type-graphql/dist/utils/buildSchema.js:9:61)
  at createGraphQLServer (node_modules/@tidal/api-graphql/dist/index.js:21:41)
  at nuxt.hook (node_modules/@tidal/api-graphql/module/module.js:53:37)
MichalLytek commented 4 years ago

I know, I added this guard after v14 release as I received tons of issues from people don't paying attension to npm warns about incorrect peer dependencies.

That's why I've added "technically" - you would need to monkey-patch the exports.ensureInstalledCorrectGraphQLPackage function in graphql-version.js file πŸ˜‰

rchl commented 4 years ago

I'm not willing to mess with monkey patching. I'd rather update to graphql 15 and live with the warnings if there are no actual issues.

It's not pretty though...

npm WARN @apollographql/graphql-language-service-interface@2.0.2 requires a peer of graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @apollographql/graphql-language-service-parser@2.0.2 requires a peer of graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @apollographql/graphql-language-service-types@2.0.2 requires a peer of graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @apollographql/graphql-language-service-utils@2.0.2 requires a peer of graphql@^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN apollo-graphql@0.4.4 requires a peer of graphql@^14.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN apollo-link-persisted-queries@0.2.2 requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-query-complexity@0.5.0 requires a peer of graphql@^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-subscriptions@1.1.0 requires a peer of graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-tag@2.10.3 requires a peer of graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN graphql-upload@8.1.0 requires a peer of graphql@0.13.1 - 14 but none is installed. You must install peer dependencies yourself.
npm WARN subscriptions-transport-ws@0.9.16 requires a peer of graphql@^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.1 || ^14.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN vue-cli-plugin-apollo@0.21.3 requires a peer of @vue/cli-shared-utils@^3.0.0 || ^4.0.0-0 but none is installed. You must install peer dependencies yourself.
robhogan commented 4 years ago

1.0.0-rc.1 is working well for us, thanks very much!

I'd like to propose https://github.com/MichalLytek/type-graphql/pull/639 is included in 1.0.0 to fix the one remaining peer dependency incompatibility with graphql@15.

jeromeSH26 commented 4 years ago

hi, have upgrade to rc2 today, as well as graphql V15.0.0 and graphql-tools 6.0.9. I lost some inheritance in the @interfacetype. For example some typeorm entites were extending a base entity with a column "id". Compiling was ok but at run time I got an error Interface: [interface] expects β€œfieldname” but [type] does not provide it. I change the interfaces and type definition to add the missing field and it worked ok.

Don't know if this issue is related to rc2 or to the graphql V15.0.0

Good job anyway, thks a lot

MichalLytek commented 4 years ago

@jeromeSH26 please isolate the issue and create a minimal reproducible code example

jeromeSH26 commented 4 years ago

here is a simplifed example (most of the interfaces and objects are in different files, I have put then all together for the example)

import { InterfaceType, Field, ID, ObjectType } from "type-graphql";
import { BaseEntity, Column, Index, Generated, Entity, PrimaryColumn } from "typeorm";

export interface IBasicEntityId {
    id: string;
};

@InterfaceType()
export abstract class GqlBasicId implements IBasicEntityId  {
    @Field(() => ID, { nullable: false })
    id: string;
};

export interface ITheEntity extends IBasicEntityId {
    field1: string;
    field2: boolean;
};

@InterfaceType()
export abstract class GqlTheEntity extends GqlBasicId
    implements ITheEntity{
       // uncommenting the next  2 lines fix the issue. But in v0.17.6 and graphql 14.6.0 no need these 2 lines. Inheritance was ok
    // @Field(() => ID, { nullable: false }) 
    // id: string; 
    @Field({ nullable: false })
    field1: string;
    @Field(() => Boolean, { nullable: true })
    field2: boolean;
    };

// typeorm defs
export class MyBaseEntity extends BaseEntity {
    @Column()
    @Index()
    @Generated("uuid")
    id: string;
};

//final objects

@ObjectType({ implements: GqlTheEntity })
@Entity({
    name: "test",
})
export class TheEntity extends MyBaseEntity
    implements ITheEntity{
    @PrimaryColumn({
        type: "character varying",
        length: 20,
        nullable: false,
        default: "",
    })
    field1: string;

       @Column({
        type: "bool",
        nullable: false,
        default: true,
    })
    field2: boolean;
};

error : Interface field GqlTheEntity .id expected but TheEntity does not provide it.

MichalLytek commented 4 years ago

@jeromemeichelbeck Looks like it might be related to #373 and I don't have an idea how to solve that issue properly πŸ˜•

jeromeSH26 commented 4 years ago

maybe, but it's weird because it was working fine before. I will try to downgrade graphql and/or type-graphql to find which one create this regression.

it's not a big deal however although it reduces the scope of inheritance for large or shared librairies.

mqdeandrade commented 4 years ago

Going from RC2 to RC3 uncovered some hidden errors in my entity definitions that took a bit of head scratching to find. I had defined a field as @Field(_type => Payment, { nullable: true }) with a typeorm OneToMany and a field resolver defined as @FieldResolver(_returns => [Payment]). The error is pretty obvious when you look at them side by side but it was working happily on RC2. Going to RC3 threw a 'non-nullable field can't be null error' when querying the parent entity. The fix was simply removing the @Field as per the docs because the @FieldResolver was doing the job anyway, although I could have just defined the _type as [Payment] as well which would have worked too.

MichalLytek commented 4 years ago

@mqdeandrade Thanks for sharing this info. As stated in the release notes, RC3 has removed the legacy array inference, so now explicit array syntax ([Item]) is required. The first releases didn't support the array [Item] syntax, only isArray: true option, so now I'm just removing the old deprecated, not used in docs approach as a part of cleaning before the 1.0.0 release.

ofbeaton commented 4 years ago

graphql-subscriptions which type-graphql v1-rc3 relies on does not support graphql v15.

Fresh "type-graphql": "^1.0.0-rc.3" with graphql v15 "graphql": "^15.3.0",

I get a warning npm WARN graphql-subscriptions@1.1.0 requires a peer of graphql@^0.10.5 || ^0.11.3 || ^0.12.0 || ^0.13.0 || ^14.0.0 but none is installed. You must install peer dependencies yourself.

They have an open issue for graphl v15 support from April 2nd, still unresolved. https://github.com/apollographql/graphql-subscriptions/issues/221

Perhaps type-graphql should stick with graphql v14 for now? Or can I safely ignore this warning?

MichalLytek commented 4 years ago

@ofbeaton Yes, you can safely ignore this warning - breaking changes in v15 were really small and minor, all my test suite with subscriptions work without any issues with v15 πŸ˜‰

MichalLytek commented 4 years ago

TypeGraphQL 1.0 has been finally released! πŸŽ‰ https://dev.to/michallytek/announcing-typegraphql-1-0-1d7h

You can read full changelog here: https://github.com/MichalLytek/type-graphql/releases/tag/v1.0.0

Thank you guys for the amazing support! ❀️ Closing this one for a housekeeping purposes πŸ”’