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

Fix Torii graphql type name collision #1086

Merged
merged 18 commits into from
Oct 30, 2023
Merged

Conversation

gianalarcon
Copy link
Contributor

@gianalarcon gianalarcon commented Oct 23, 2023

Resolves #1032

Redefine graphql types like {Model}_{CustomType/NestedType}

type Record {
  type_contract_address: ContractAddress
  type_nested: Record_Nested
}

type Record_Nested {
 depth: u8,
 type_number: u8,
}

It is working for some queries, but for some of them it is failing
Reason is GraphQL query returned errors: [ServerError { message: "error returned from database: (code: 1) no such table: Record$Record_Nested

Indeed we have Record$Nested table, but we dont have Record$Record_Nested table.

So the side effect to redefine names of graphql types is that we have rename as well some tables names on our database.

@broody I am going on the right way? Any suggestion about this? Thanks

@broody
Copy link
Collaborator

broody commented Oct 24, 2023

Looks like good way to do it. Instead of renaming, perhaps we could remove the prefix here when constructing the table name for nested type:

let table_name = path_array.join("$");

@gianalarcon
Copy link
Contributor Author

gianalarcon commented Oct 24, 2023

Looks like good way to do it. Instead of renaming, perhaps we could remove the prefix here when constructing the table name for nested type:

let table_name = path_array.join("$");

I see, so, for this example, for current Record$Nested table name, we have to change into Record_Nested table name, right?
We dont have to use path_array.join() anymore is it?

@broody
Copy link
Collaborator

broody commented Oct 24, 2023

I see, so, for this example, for current Record$Nested table name, we have to change into Record_Nested table name, right? We dont have to use path_array.join() anymore is it?

I mean let's avoid renaming table and just remove prefix in path array. For example, the doubly nested member NestedMore, new path array with ur current change would be ["Record", "Record_Nested", "Record_NestedMore"], just need to transform it to match table name Record$Nested$NestedMore

@gianalarcon
Copy link
Contributor Author

@broody I think I am done. Please check here.
I just left some prints in case I need. After you approved this PR I will remove them.

Copy link
Collaborator

@broody broody left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working good, just some suggestions to provide more context

crates/torii/graphql/src/object/entity.rs Outdated Show resolved Hide resolved
crates/torii/graphql/src/object/model_data.rs Outdated Show resolved Hide resolved
crates/torii/graphql/src/query/mod.rs Outdated Show resolved Hide resolved
@gianalarcon gianalarcon marked this pull request as ready for review October 25, 2023 02:59
@gianalarcon
Copy link
Contributor Author

gianalarcon commented Oct 25, 2023

Hi @broody. I added your suggestions, indeed they are meaningful and useful for developer documentation

@gianalarcon gianalarcon marked this pull request as draft October 26, 2023 15:25
@gianalarcon gianalarcon marked this pull request as ready for review October 26, 2023 15:32
@broody broody merged commit f1e33f7 into dojoengine:main Oct 30, 2023
11 checks passed
@gianalarcon gianalarcon deleted the collision branch November 24, 2023 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Torii graphql type name collision
2 participants