Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Duplicated GraphQL Types with custom resolvers

default discord avatar
atrevid000last year

I am using GraphQL codegen in clients to generate types based off Payload schema. I'm noticing that when I define my own resolvers, e.g.



      ShowsByCategory: {
        type: buildPaginatedListType(
          'shows',
          payload.collections.shows.graphQL?.type
        ),
        args: {
          categoryName: {
            type: new GraphQL.GraphQLNonNull(GraphQLString),
          },
        },
        resolve: showsByCategoryResolver,
      },


The GraphQL schema duplicates the definition of Shows. Is there anyway around this happening?



Okay actually I figured it out, the first argument in buildPaginatedListType 'shows' defines the name of the object in the schema. I simply gave it a unique name "ShowsByCategory" and it resolves the issue.



Also annoyingly, the reason it worked before is because 'shows' was lower case so I had two definitions in the schema Shows and shows

    Star on GitHub

    Star

    Chat on Discord

    Discord

    online

    Can't find what you're looking for?

    Get dedicated engineering support directly from the Payload team.