Connecting Payload CMS to Next.js more seamlessly?

default discord avatar
Jakey
8 months ago
12

I'm curious if this sounds crazy or not, but I'm looking to take the GQL queries Payload CMS makes possible and automatically make them available on the Next.JS side of my application.



Is there a tool or common methodology for this? I noticed types and schema are exportable by default. Not sure if these are related to a potential solution.



I discussed this with my team and it seems like the tradeoff is to either use REST to not have to define GQL requests and have less control over the request size or use GQL but have to maintain the Query strings.



We opted for the latter and just to improve our interface for making requests. If there's any feedback as to why this would be a terrible idea, let me know lol.

  • default discord avatar
    Alessio 🍣
    8 months ago

    not sure if I understand the problem 10=%, but wouldn't exporting the GQL Schemas and importing them in your IDE do that? It should give you autocompletion in your IDE

  • default discord avatar
    Jakey
    8 months ago

    autocompletion isn't a huge concern for me atm. but yeah you're right that that should do that for me.



    The issue is that any time I update fields in Payload, I have to go over to the Next.js side and make sure it's sync'd up.



    Ultimately though, it's hard to tell what fields you want to keep and want to exclude in an automated fashion so we prefer to keep that maintenance layer going and to just do what we can to make that a clean process.

  • default discord avatar
    Alessio 🍣
    8 months ago

    I think the IDE can automatically download / update the gql definitions! There's a fancy plugin for intellijs which does that, for example



    I swear to god this was mentioned somewhere in this discord but I cannot find it - it was months ago



    https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/docs/developer-guide

    I think I used this plugin for intellij



    you can add a remote schema there



    and in there you specify the gql endpoint or sth like that

  • default discord avatar
    Jakey
    8 months ago

    interesting... I'll def take a look! Thanks @Alessio 🍣

  • default discord avatar
    Alessio 🍣
    8 months ago

    You're welcome!



    oh shame on me



    I insulted intellij by calling it


    "Intellijs"

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.