mercurius-js / mercurius-typescript

TypeScript usage examples and "mercurius-codegen" for Mercurius

Home Page:https://mercurius.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SelectionNode or InlineFragmentNode are badly typed

mortifia opened this issue · comments

im using this to get requested arg at actual level

    async (parent, args, ctx, info) => {
      const fields = info.fieldNodes[0].selectionSet?.selections.map(info => {
        return info.name.value
      })
    }

ts send this error

La propriété 'name' n'existe pas sur le type 'SelectionNode'.
  La propriété 'name' n'existe pas sur le type 'InlineFragmentNode'.ts(2339)
  
Property 'name' does not exist on type 'SelectionNode'.
  Property 'name' does not exist on type 'InlineFragmentNode'.ts (2339)

but info var is as foliwing

[
    {
        "kind": "Field",
        "name": {
            "kind": "Name",
            "value": "id",
            "loc": {
                "start": 16,
                "end": 18
            }
        },
        "arguments": [],
        "directives": [],
        "loc": {
            "start": 16,
            "end": 18
        },
        "__internalShouldInclude": "true"
    },
    {
        "kind": "Field",
        "name": {
            "kind": "Name",
            "value": "title",
            "loc": {
                "start": 23,
                "end": 28
            }
        },
        "arguments": [],
        "directives": [],
        "loc": {
            "start": 23,
            "end": 28
        },
        "__internalShouldInclude": "true"
    }
]

This types issue is most likely fixed with GraphQL v16, since now graphql-js is full typescript, but Mercurius itself still doesn't support v16: mercurius-js/mercurius#628