Duplicated GraphQL Types with custom resolvers

default discord avatar
atrevid000
last month

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

    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.