khaosdoctor / gotql

GraphQL query utility for serverside apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Empty TypeScript declaration file

screendriver opened this issue · comments

Describe the bug

The package that is deployed to npm does not include anything in index.d.ts. It looks like this:

export {};
//# sourceMappingURL=index.d.ts.map

To Reproduce
Steps to reproduce the behavior:

  1. npm install gotql
  2. Open node_modules/gotql/dist/index.d.ts

Current behavior

This package can't be used in a TypeScript project.

Expected behavior

Types should be deployed within that package.

Weird! Let me look into this right now

@screendriver can you please test it again?

Thanks for the heads up!

@screendriver can you please test it again?

Nothing changed with 1.6.1. Same problem.

The 1.6.1 tag got behind the latest commit, I think it was some sort of racing condition. Created 1.6.2 pointing to the latest, should fix the problem

It works now with 1.6.2. But the next problem is UserOptions. It is an object with a property called errorStatusCode with the description Default error code to send back to the user on error (defaults to 500). But if you look at your types it is not optional. That means that following will not compile because I do not define errorStatusCode:

await gotQl.query('https://foo.bar/graphql', query, {
  headers: {
    Authorization: `Bearer ${secret}`,
  },
});

@screendriver Thanks! Fixed on 1.6.3

I have the next one. Should I create a new issue for that?

const mutation = {
  operation: {
    name: 'test',
    args: {
      id: 'one',
      data: {
        name: 'two',
        status: 'three',
      },
    },
    fields: [{ data: { fields: ['one', 'two'] } }],
  },
};

Does not work with TypeScript because args is defined as

args?: {
  [name: string]: string | ArgObject;
};

export declare type ArgObject = {
    value: string;
    escape: boolean;
};

That means that that you can't set objects as value (like data in my example). Only strings or objects with { value: '', escape: true/false }

@screendriver If you could please fill in another issue about this, so I can take a better look 🙂