cnj-digital / seotamic

A Statamic v4 SEO addon
20 stars 13 forks source link

seotamic v5.0@beta Issue fetching with GraphQL #75

Closed Kylewalow closed 2 days ago

Kylewalow commented 1 month ago

cnj/seotamic v5.0@beta statamic/cms v^5.0 Headless with GraphQL

We're encountering a problem while fetching data from Seotamic using GraphQL:

query MyQuery {
  entry(uri: "/") {
    title
    ... on Entry_Pages_Page {
      title
      seotamic_meta
    }
  }
}

We received the following debugMessage:

"debugMessage": "Expected a value of type String but received: {\"title\":\"Startseite Baryon AG\",\"description\":\"Als unabh\u00e4ngiges, erfahrenes Unternehmen spezialisieren wir uns auf Verm\u00f6gensverwaltung sowie Steuer-, Unternehmens- und Rechtsberatung.\",\"canonical\":\"http:\/\/localhost:3000\/\",\"robots\":\"\",\"related\":[{\"lang\":\"en\",\"href\":\"http:\/\/localhost:3000\/en\"}]}. String cannot represent value: {\"title\":\"Startseite Baryon AG\",\"description\":\"Als unabh\u00e4ngiges, erfahrenes Unternehmen spezialisieren wir uns auf Verm\u00f6gensverwaltung sowie Steuer-, Unternehmens- und Rechtsberatung.\",\"canonical\":\"http:\/\/localhost:3000\/\",\"robots\":\"\",\"related\":[{\"lang\":\"en\",\"href\":\"http:\/\/localhost:3000\/en\"}]}"

Based on my understanding, seotamic_meta should have a subselection like this:

seotamic_meta {
  canonical
  description
  robots
  title
}

However, this results in the following message: "Field 'seotamic_meta' of type 'String' must not have a sub-selection."

Is this a bug, or am I missing some settings? Thank you for your help.

martink635 commented 1 month ago

Hey, thanks for the report!

Is this an issue only on v5? Is this a new website or something you've updated to v5?

Kylewalow commented 1 month ago

Thank you for your fast response. In all our v4 projects, it works. It's a newly created v5 Statamic project, which already had some content, in which we implemented Seotamic yesterday with:

composer require cnj/seotamic

We're using Statamic headless with a Nuxt3 frontend. I've tested and encountered the behavior in the Statamic GraphQL editor and when fetching from the frontend.

martink635 commented 1 month ago

I just did some tests on my test install, with some content, and GraphQL works fine for me.

Are you able to share the non working project with me? A zip is also fine if you can't add me to the repository. You can send the zip to martin@cnj.si

Screenshot 2024-08-09 at 14 16 16

Kylewalow commented 4 weeks ago

Sorry for the long response time.

I'm afraid I'm not allowed to share the non-working project, but I tested it with a newly created Statamic project and encountered the same problem.

Way to reproduce:

1. Create a New Statamic Project: Run statamic new statamic_test to install Statamic version 5.21.0.

2. Configure Environment Settings: In the .env file, enable PRO features and GraphQL with:

STATAMIC_PRO_ENABLED=true
STATAMIC_GRAPHQL_ENABLED=true

3. Configure GraphQL Settings Configure the resources in graphql.php as follows:

    'resources' => [
        'collections' => true,
        'navs' => true,
        'taxonomies' => true,
        'assets' => true,
        'globals' => true,
        'forms' => true,
        'sites' => true,
        'users' => true,
    ],

4. Install Seotamic: Run composer require cnj/seotamic.

Then in the GraphQL Editor: image

A subselection is not allowed: image

Statamic: v5.21.0 cnj/seotamic: v5.0.0

Kylewalow commented 2 weeks ago

Are there any updates on this? Our release date is approaching, and I’m really hoping to use SEOtamic as part of it.

martink635 commented 2 weeks ago

Not yet, we are bit thinned out due to vacations, I will get to this soon, hopefully by the end of this week or early next week.

martink635 commented 1 week ago

I've tried reproducing but failed :/

I did install the Cool Writings starter kit to have some content.

And what I did differently I've added the seotamic pro edition in editions.php

<?php

return [

    'pro' => env('STATAMIC_PRO_ENABLED', false),

    'addons' => [
        'cnj/seotamic' => 'pro'
    ],

];

My query gets autocompleted if I put in seotamic_meta with the additional fields automatically as I run the query or press enter.

Screenshot 2024-09-06 at 09 13 42
❯ php please support:details

Environment
Application Name: Statamic
Laravel Version: 11.22.0
PHP Version: 8.3.10
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: statamic_test.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: NOT CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 1
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.24.0 PRO

Statamic Addons
cnj/seotamic: 5.0.0
Kylewalow commented 2 days ago
    'addons' => [
        'cnj/seotamic' => 'pro'
    ],

This solved the problem. As far as I’m concerned, you can close this issue. Thank you very much for your help!

martink635 commented 2 days ago

No worries, glad we sorted it out!