statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
3.7k stars 508 forks source link

Type NavPage_* must define one or more fields error in GraphiQL #10621

Open 321zeno opened 1 month ago

321zeno commented 1 month ago

Bug description

I created a new Statamic project, enabled pro and GraphQL locally and created a super user for the CP.

I created a new Navigation called "Test"

When I open GraphiQL if fails to fetch the schema with the message

Type NavPage_Test must define one or more fields.,

How to reproduce

The error message Type NavPage_Test must define one or more fields.", shows up Also the nav() query is not visible in the Explorer (only ping)

Logs

Nothing in the logs

Environment

Environment
Application Name: Statamic
Laravel Version: 11.20.0
PHP Version: 8.3.6
Composer Version: 2.2.6
Environment: local
Debug Mode: ENABLED
URL: localhost
Maintenance Mode: OFF
Timezone: UTC
Locale: en

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

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

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

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

321zeno commented 1 month ago

I'm not sure why it wasn't working, but it's working now, possibly the cache took a while to update, closing.

lotarbo commented 1 week ago

@duncanmcclean Hi, i have same error. Upgraded from version 4 to version 5. Statamic Version: 5.24.0

 {
      "message": "Type NavPage_Footer must define one or more fields.",
      "extensions": {},
      "stack": "GraphQLError: Type NavPage_Footer must define one or more fields.\n    at SchemaValidationContext.reportError (https://unpkg.com/graphiql/graphiql.min.js:34515:23)\n    at validateFields (https://unpkg.com/graphiql/graphiql.min.js:34632:13)\n    at validateTypes (https://unpkg.com/graphiql/graphiql.min.js:34611:7)\n    at Object.validateSchema (https://unpkg.com/graphiql/graphiql.min.js:34491:3)\n    at https://unpkg.com/graphiql/graphiql.min.js:71072:20\n    at updateMemo (https://unpkg.com/react-dom@18/umd/react-dom.development.js:16437:21)\n    at Object.useMemo (https://unpkg.com/react-dom@18/umd/react-dom.development.js:17077:18)\n    at Object.useMemo (https://unpkg.com/react@18/umd/react.development.js:1640:23)\n    at SchemaContextProvider (https://unpkg.com/graphiql/graphiql.min.js:71068:34)\n    at renderWithHooks (https://unpkg.com/react-dom@18/umd/react-dom.development.js:15496:20)"
    },

That's how my footer blueprint looks

image

What i also do after upgrade:

  1. clear all in Cache Manager
  2. php artisan optimize:clear
  3. composer dumpautoload

There were no problems in version 4

321zeno commented 1 week ago

Yeah, I can confirm that the error still pops up for me, with a small correction from my original ticket

The error message Type NavPage_Test must define one or more fields.", shows up

  • this still happens Also the nav() query is not visible in the Explorer (only ping)
  • this is visible in the Explorer and works when querying
jasonvarga commented 1 week ago

I believe this happens when you have a nav and haven't added any fields to the blueprint.

You shouldn't need to, but if you want to work around it until a fix is ready, you can just add a hidden field to the blueprint.