graphql-zeus icon indicating copy to clipboard operation
graphql-zeus copied to clipboard

Gql() variables are not type-safe

Open ValentinH opened this issue 3 years ago • 10 comments

While playing with the new changes introduced in v5, I noticed that Apollo queries and mutations variables can now be made typesafe by using the typedGql helper (as documented here).

However, I noticed that the barebone version of using the Gql function isn't type-safe. Is it a known limitation?

From the examples (https://github.com/graphql-editor/graphql-zeus/blob/master/examples/typescript-node/src/index.ts#L241-L273):

  const aliasedQueryExecute = await Gql('query')(
    {
      listCards: {
        __alias: {
          namy: {
            name: true,
          },
          atak: {
            attack: [
              { cardID: $('cardIds', '[String!]!') },
              {
                name: true,
                __alias: {
                  bbb: {
                    Defense: true,
                  },
                  ccc: {
                    Children: true,
                  },
                },
              },
            ],
          },
        },
        id: true,
      },
    },
    {
      variables: {
        cardIds: ['aaa'],
      },
    },
  );

It is using the $() function and providing a graphql type but I can pass any data to cardIds without any type error.

ValentinH avatar Sep 07 '22 10:09 ValentinH

Possible duplicate of #232 (???)

IceBlizz6 avatar Sep 08 '22 11:09 IceBlizz6

No this is a different topic.

ValentinH avatar Sep 09 '22 05:09 ValentinH