graphjin icon indicating copy to clipboard operation
graphjin copied to clipboard

wrong relation resolving in multiple schemas environment

Open inf-initely opened this issue 2 years ago • 2 comments

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: image 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

inf-initely avatar Aug 19 '23 23:08 inf-initely

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?

inf-initely avatar Aug 19 '23 23:08 inf-initely

Is this still an issue for you will look into fixing it.

dosco avatar May 28 '24 17:05 dosco