Open skarger opened 5 years ago
My first thought is that the issue is related to #18, as you mentioned. There are some related records in the tests but I think the add-on currently expects them to be associated in a certain way, which isn't very flexible.
Here is an example: https://github.com/kloeckner-i/ember-cli-mirage-graphql/blob/master/tests/acceptance/customer-test.js#L11. Are you able to relate your records like this for the time being?
@jneurock OK, looks like that example uses the customer and order factories to create a relationship, rather than Mirage hasMany
/ belongsTo
relationships. That will potentially work for me, I'll give it a try.
I watched the same video guide. I’ve been trying to get hasMany
relationships to work. One-to-one belongsTo
relationships work fine. I’m using factories for every model in my default Scenario
.
@skarger Have you been able to get a hasMany
relationship working in development (not just in tests)?
I’m thinking of adding a default Scenario to the dummy app to see if it works in development.
@dmzza no, but I haven't tried yet.
If you'd like, feel free to fork and add a failing test, or add an example to the dummy app that doesn't work, so I can see where the addon is breaking down.
After a lot of exploration, I found the most significant cause of the problem for me. I'm transitioning from ember-data to GraphQL, and I didn't want to delete my ember-data models yet. So Mirage was reading my models and that broke all of my hasMany
relationships.
To fix that, I added this to config/environment.js
:
ENV['ember-cli-mirage'] = {
discoverEmberDataModels: false
};
Now I can keep all of my models so that my typescript still compiles while I make the transition from ember-data to GraphQL.
However, I also found some inconsistent behavior with the way I construct my relationships using factories. I'm still investigating this, and if I can produce the same problem in the sample app, I might open a PR.
Ah, very interesting. Thanks for the info. Feel free to open a PR. If you think something should be added to the README to help others with the same situation, feel free to add something there, too.
This addon will be deprecated in favor of https://github.com/miragejs/graphql which does use Mirage models.
I'm using the currently released
ember-cli-mirage-graphql
version,0.1.1
.This video guide about
ember-cli-mirage-graphql
uses Mirage factories, and so does this repo's dummy app.Mirage also provides the concepts of models and relationships. Specifically, you can define
belongsTo
andhasMany
relationships between models.I tried using Mirage models in my app, but when handling the GraphQL query it seemed to have trouble loading the related models. I'm not sure if I was lacking some necessary configuration or it's just not supported.
By the way, this may be tangentially related to #18.