graphjin
graphjin copied to clipboard
wrong relation resolving in multiple schemas environment
What version of GraphJin are you using? graphjin version
github.com/dosco/graphjin/core/v3 v3.0.0-20230605081643-067f320de10a
Have you tried reproducing the issue with the latest release?
Yes
Specs
- DB:
mysql
Steps to reproduce the issue (config used to run GraphJin).
Needs 2 or more schemas with at minimum 2 related tables.
- Create a schema with basic table relationship, such as
news.user_id->user.id - Duplicate schema 2 or 3 times
- Connect to one of the schema
- Do simple query AT other schema such as:
query MyQuery {
news @schema(name:"client_01") {
user_id
users {
id
}
}
}
- Graphjin will sometimes relate the table to wrong schema
Observed behaviour
After debugging the library, it seems the resolver for relational info is implemented with shortest path logic and didn't take into account which schema the root/parent table came from, hence sometimes will yield wrong edgeinfo.
For example, i have duplicated my schema and prefixed the duplicate with test.
Querying this:
query MyQuery {
artikels @schema(name:"local_jalremp") {
status
id
artikel_kategori_show {
id
kategori_show {
isi
}
}
}
}
Yields sql:
Notice how it referencing wrong schema (expected:
local_jalremp, got: local_jalremp_test)
Expected behaviour and actual result.
Table relationship resolving need to take into account the schema of the parent
Unrelated to the issue but worth mentioning, for query:
query MyQuery {
news @schema(name:"client_01") {
user_id
users @schema(name: "client_01") {
id
}
}
}
@schema directive is properly applied to child fields (in this case, users), but inherent table relationship takes precedence over qcode.Select.Schema, is this an intended behaviour?
Is this still an issue for you will look into fixing it.