sikanhe / gqtx

Code-first Typescript GraphQL Server without codegen or metaprogramming
458 stars 13 forks source link

Support for graphql 16 #61

Closed tonyxiao closed 10 months ago

tonyxiao commented 2 years ago

Right now package.json says "graphql": "^15.1.0",. Does that mean 16 is not supported?

sikanhe commented 2 years ago

Depend on if Graphql-js has breaking changes or not - have you discovered any API incompatibility so far?

Emilios1995 commented 2 years ago

I just discovered one incompatibility. In GraphQL 16, resolveType functions can no longer return a GraphQLObjectType—it now has to be the type name as a string. gqtx currently doesn't support returning strings.

mfulton26 commented 1 year ago

I am seeing type inconsistencies too and would love to see a new release of gqtx for graphql@16.

sikanhe commented 1 year ago

There is a new release thats coming up that works with graphql@16, but it also has a bit of library API change along with that peer dependency upgrade: https://github.com/sikanhe/gqtx/pull/71 (API changes: https://github.com/sikanhe/gqtx/pull/71/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5)

What is the type inconsistencies you are seeing? @mfulton26

I think the only run I have run into is that resolveType can only return a string name now.

mfulton26 commented 1 year ago

It was something about a private type not being present. It was confusing. I'll see if I can reproduce and share.

mfulton26 commented 1 year ago

I was getting this error but I think this was from how I was using it. I'm exploring options for type-safe GraphQL schema building for deploying code to Deno Deploy and I was getting the following errors:

  1. TypeScript type checking error:

    Type 'GraphQLSchema' is missing the following properties from type 'GraphQLSchema': __validationErrors, _queryType, _mutationType, _subscriptionType, and 6 more.
  2. Runtime error:

    Error: Cannot use GraphQLSchema "{ __validationErrors: undefined, description: undefined, extensions: undefined, astNode: undefined, extensionASTNodes: undefined, _queryType: Query, _mutationType: undefined, _subscriptionType: undefined, _directives: [@include, @skip, @deprecated, @specifiedBy], _typeMap: { Query: Query, User: User, ID: ID, Role: Role, String: String, Boolean: Boolean, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _subTypeMap: {}, _implementationsMap: {} }" from another module or realm.
    
    Ensure that there is only one instance of "graphql" in the node_modules
    directory. If different versions of "graphql" are the dependencies of other
    relied on modules, use "resolutions" to ensure only one version is installed.
    
    https://yarnpkg.com/en/docs/selective-version-resolutions
    
    Duplicate "graphql" modules cannot be used at the same time since different
    versions may have different capabilities and behavior. The data from one
    version used in the function from another could produce confusing and
    spurious results

I replaced my import npm:gqtx@^0.8.1 with https://esm.sh/gqtx@0.8.1?external=graphql and now it is working. I don't know if Deno's NPM specifiers support any "external" option like ESM.sh.

sikanhe commented 10 months ago

Supported in 0.9.0+