sikanhe / gqtx

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

Docs update needed. #57

Closed spa5k closed 3 years ago

spa5k commented 3 years ago

When we try to directly use the example from README.md

const UserType = t.objectType<User>({
  name: 'User',
  description: 'A User',
  fields: () => [
    t.field({ name: 'id', type: t.NonNull(t.ID) }),
    t.field({ name: 'role', type: t.NonNull(RoleEnum) }),
    t.field({ name: 'name', type: t.NonNull(t.String) }),
  ],
});

The Typescript compiler starts giving this error - Expected 2 arguments, but got 1.ts(2554)

Looking into the types in node_modules, It looks like it has been changed to -

field(name: string, { type, args, resolve, description, deprecationReason, }

And when I try to use it, compiler starts giving warning that resolve needs to be added.

I'm not sure how should be handled since even in docs resolve has only been added in queryType not in objectType. How it should be handled?