Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
321zeno opened this issue Aug 13, 2024 · 4 comments
Open

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

321zeno opened this issue Aug 13, 2024 · 4 comments

Comments

@321zeno
Copy link

321zeno commented Aug 13, 2024

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-nav
  • php please make:user
  • Enable GraphQL in .env
  • enable resources.navs in statamic-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

@321zeno
Copy link
Author

321zeno commented Aug 13, 2024

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

@lotarbo
Copy link

lotarbo commented Sep 3, 2024

@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

@duncanmcclean duncanmcclean reopened this Sep 4, 2024
@321zeno
Copy link
Author

321zeno commented Sep 4, 2024

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

@321zeno 321zeno changed the title GraphQL not working for new Navigation Type NavPage_* must define one or more fields error in GraphiQL Sep 4, 2024
@jasonvarga
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants