craft-linkfield icon indicating copy to clipboard operation
craft-linkfield copied to clipboard

Inconsistencies whereby some instances of the field do not allow subsets and returns a string only | GraphQL + linkfield 2.0.0-rc.1

Open toddpadwick opened this issue 3 years ago • 5 comments

I have a strange issue, that despite clearing cache, re-installing and re-creating fields, some instances of the linkfield do not allow any subsets whereas others do. For example:

This works (supertable field inside a matrix)

    cta {
        ... on cta_BlockType {
          linkTo {
            url
            element {
              slug
              uri
              id
              title
            }
            text
          }
          weight
        }
      }
    }

returns successfully:

        "cta": [
            {
              "linkTo": {
                "url": "https://cms.protopixel.io/showcase",
                "element": {
                  "slug": "showcase",
                  "uri": "showcase",
                  "id": "1024",
                  "title": "Showcase"
                },
                "text": "Find out how"
              },
              "weight": "tertiary"
            }
          ]

This doesn't work (supertable field inside a global)

    ... on footer_GlobalSet {
      utilityNav {
        ... on utilityNav_group_BlockType {
          label
          links {
            ... on links_BlockType {
              linkTo {
                url
                text
              }
            }
          }
        }
      }
    }

returns error:

    {
      "errors": [
        {
          "message": "Field \"linkTo\" of type \"String\" must not have a sub selection.",
          "extensions": {
            "category": "graphql"
          },
          "locations": [
            {
              "line": 10,
              "column": 22
            }
          ]
        }
      ]
    }

I have tried the following:

  • Turning the field into a string field, saving, then clearing cache, then re-saving as a link field again
  • deleting vendor and re-installing
  • re-building yaml files
  • re-generating all yaml updates

toddpadwick avatar Sep 01 '21 09:09 toddpadwick

That's a really odd behavior and I don't have a quick explanation. How does the schema describe those fields?

sebastian-lenz avatar Sep 01 '21 17:09 sebastian-lenz

I know right? its a wierd one that i've not experienced before.

For the footer global set the Schema describes 'linkTo' as a string. For the matrix field, it describes it as a linkField_Link.

However, I can be sure that the field is a linkField as it has the linkField options in the CMS admin - see screenshot:

Screenshot 2021-09-02 at 12 12 43

So why might this not be updating in GraphQL? other than clearing the data and graphql schema cache, or re-generating from yaml, is there something else i've missed?

toddpadwick avatar Sep 02 '21 10:09 toddpadwick

Hey @sebastian-lenz Getting a lot of weird issues like this - such as this one - is it related? https://github.com/sebastian-lenz/craft-linkfield/issues/170

toddpadwick avatar Sep 08 '21 09:09 toddpadwick

If you ironed out the v2 issues and then made this plugin a paid for install, I'd be happy to pay for it. I'm sure others would too as its the only viable link plugin with GraphQL support. Its needed on all our sites but the bugs are making things tricky :(

toddpadwick avatar Sep 08 '21 09:09 toddpadwick

I highly doubt that these issues are related. And I won't make this plugin paid, there is a commercial alternative for those who need it (e.g. for the support), this was intended to be the open and free alternative.

sebastian-lenz avatar Sep 08 '21 10:09 sebastian-lenz