Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong relation resolving in multiple schemas environment #457

Open
inf-initely opened this issue Aug 19, 2023 · 2 comments
Open

wrong relation resolving in multiple schemas environment #457

inf-initely opened this issue Aug 19, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@inf-initely
Copy link

inf-initely commented Aug 19, 2023

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 inf-initely added the bug Something isn't working label Aug 19, 2023
@inf-initely
Copy link
Author

inf-initely commented Aug 19, 2023

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?

@dosco
Copy link
Owner

dosco commented May 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants