miragejs / graphql

A library for handling GraphQL requests with Mirage JS
MIT License
74 stars 12 forks source link

Errors on schema with interfaces #42

Closed bombillazo closed 1 year ago

bombillazo commented 3 years ago

Given a schema with interfaces:

type Account {
  id: ID
  profile: ProfileData!
} 

interface Profile {
  email: String
  phone: String
}

type ProfileData {
  personal: PersonalProfile
  business: BusinessProfile
}

type PersonalProfile implements Profile {
  firstName: String!
  lastName: String!
  email: String
  phone: String
}

type BusinessProfile implements Profile {
  name: String!
  type: BusinessTypes
  email: String
  phone: String
}

@miragejs/graphql gets confused when trying to create Models. The attempts to create a ProfileData record using server.create('profileData') gives an error indicating there is no model nor factory available for it. In addition, a Profile model is created when there should be none since it is an interface.

jneurock commented 2 years ago

Which version of the library were you using when you encountered this issue? There are similar tests for this in the project. I modified the test schema and tests locally to more closely match your scenario and everything is working as expected.