1

I am working on a Apollo based API but am running into an issue. I am using many small schemas and typedefs to keep everything divided nicely and using the buildSubgraphSchema function to merge them all for use. but it doesn't seem to be able to recognise the resolveType for a union.

the resolveType:

Attendee: {
    __resolveType(obj) {
      if (obj.account) {
        return "User";
      }
      if (obj.companies) {
        return "Contact";
      }
      return null;
    },
  },

The schema

type Event {
  id: String
  title: String
  description: String
  creator: Contact
  task: Task
  activity_type: ActivityType
  starts_at: String
  ends_at: String
  location: String
  attendees: [Attendee]
  links: [EventLink]
}

union Attendee = Contact | User

multiple attempted places in the buildSubgraphSchema

const schema = buildSubgraphSchema([
  {
    typeDefs: gql`
      extend schema
        @link(
          url: "https://specs.apollo.dev/federation/v2.0"
          import: ["@key", "@shareable"]
        )
      type Query
      type Mutation
      ************************
      `,
    resolvers: {
      Query: {
         ...calendar_events.resolvers.Attendee,
      },
      Mutation:{********}
      Attendee: {
         ...calendar_events.resolvers.Attendee,
      },

0 Answers0