Schema response does not contain foreign keys
See original GitHub issueHi there, I’m successfully using factories to create multiple records with associated records (as per the website instructions and as shown in the extract below).
However, the return schema.logEntries.all();
produced records do not contain the logLineIds
field with the foreign keys. I am 100% they exist in the db
because when I use the commented last-line in below example it does yield the expected result.
Am I missing something obvious here or am I expecting something that is not supported?
models: {
logEntry: Model.extend({
logLines: hasMany()
}),
logLine: Model.extend({
logEntry: belongsTo()
}),
},
factories: {
logEntry: logEntryFactory,
logLine: logLineFactory,
},
seeds(server) {
server.createList('logEntry', 3).forEach(logEntry => {
server.createList('logLine', 2, { logEntry })
})
},
routes() {
this.namespace = "api"; // mock all cals to `/api`
this.timing = 1200; // simulate slow networks
this.get("/log-entries", (schema) => {
return schema.logEntries.all();
//return {logEntries: server.db._collections[2]._records}
});
}
However, when I
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
3 common foreign key mistakes (and how to avoid them)
1. Mismatched data types ... When you're using a foreign key to reference a column in another table, the datatypes of both tables...
Read more >GraphQL schema on Postgres with foreign keys and without ...
Hasura GraphQL Engine allows creating relationships over Postgres tables with or without foreign keys.
Read more >Unable to create foreign key relationships in the Table Editor
Bug report Describe the bug Unable to create relationships between tables using the 'Add foreign key' function in the table editor.
Read more >How to list table foreign keys - Stack Overflow
You can do this via the information_schema tables. For example: SELECT tc.table_schema, tc.constraint_name, tc.table_name, kcu.column_name, ...
Read more >Loose foreign keys - GitLab Docs
Most of our database tables have foreign keys. With the ongoing database decomposition work, linked records might be present on two different database...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having a similar issue to @benjamindavid. The response I’m trying to mock:
I’ve setup the serializer to always include id’s and embed the includes, but the
user_id
isn’t included in the response:Is there a way to customize the serializer to include the foreign id in the embedded resource?
If I’m understanding the behavior correctly, this is currently impossible?
https://github.com/miragejs/miragejs/blob/master/lib/serializer.js#L705