Type NavPage_* must define one or more fields error in GraphiQL
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
composer create-project --prefer-dist statamic/statamic statamic-navphp please make:user- Enable GraphQL in .env
- enable
resources.navsinstatamic-nav/config/statamic/graphql.php php artisan serve- Create a new navigation called "Test"
- (optional) Create a new item in the nav
- Visit http://localhost:8000/cp/graphiql and refetch schema
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
I'm not sure why it wasn't working, but it's working now, possibly the cache took a while to update, closing.
@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
What i also do after upgrade:
- clear all in Cache Manager
- php artisan optimize:clear
- composer dumpautoload
There were no problems in version 4
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
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.
@jasonvarga Hi, I understand that the hidden field is a temporary solution. But is there a fix planned soon?