web-ridge / gqlgen-sqlboiler

This is a plugin for gqlgen to generate converts + filter queries and resolvers for sqlboiler
MIT License
75 stars 13 forks source link

data assignment is ignoring cases with string type #12

Closed troian closed 4 years ago

troian commented 4 years ago

In some cases function itself assigned instead of its result. In other cases it just inserts coma Some referenced functions do not actually exist in boilergql package

We have also failed some difficulties with referencing ID type. For some reason gqlgen-sqlboiler generates it as uint even though in models generated by sqlboiler it definitely specified as string Samples of the issue

Screen Shot 2020-05-06 at 7 54 47 PM Screen Shot 2020-05-06 at 7 50 46 PM
RichardLindhout commented 4 years ago

It could be that function does not exist (yet) in boilergql please add a PR for missing ones!

Ah in our use case we don't have string id's in database. Are you using UUID as id?

I'm generating ID's for gglgen to keep all ID's unique for Relay.dev based on uints, but that's not needed in your use case. I'll try to look into it as soon as possible.

It could simplify a lot of code if you use string id's!

RichardLindhout commented 4 years ago

It could help me a lot if you could send me a part of your database scheme or SQL with a reproduction so I could add it to https://github.com/web-ridge/gqlgen-sqlboiler-examples so your use keeps working with other releases too :)

troian commented 4 years ago

I can share SQL schema to reproduce the issue but would like to not publish it

RichardLindhout commented 4 years ago

Ok no problem I am changing existing schema to string ids to test use-case!

RichardLindhout commented 4 years ago

I have a failing reproduction repository: https://github.com/web-ridge/gqlgen-sqlboiler-examples/tree/master/issue-12-string-ids.

troian commented 4 years ago

It looks like exactly what we've got. Especially formatting :)

RichardLindhout commented 4 years ago

I'm almost done with fixes! Code is a lot cleaner when you have string id's 👍.

troian commented 4 years ago

Another note btw. GraphQL has a special type ID. Is it possible to generate with it instead of string?

type Comment {
  id: String!
  content: String!
  post: Post
  user: User!
  commentLikes: [CommentLike]
}

turns into

type Comment {
  id: ID!
  content: String!
  post: Post
  user: User!
  commentLikes: [CommentLike]
}
RichardLindhout commented 4 years ago

It should, but it has to do with string id's!

RichardLindhout commented 4 years ago

Schermafbeelding 2020-05-07 om 23 13 59 I found the bug for that. Will try to release a new version with support for string id's tomorrow!

RichardLindhout commented 4 years ago

Another note btw. GraphQL has a special type ID. Is it possible to generate with it instead of string?

type Comment {
  id: String!
  content: String!
  post: Post
  user: User!
  commentLikes: [CommentLike]
}

turns into

type Comment {
  id: ID!
  content: String!
  post: Post
  user: User!
  commentLikes: [CommentLike]
}

This issue is fixed now! https://github.com/web-ridge/sqlboiler-graphql-schema/releases

RichardLindhout commented 4 years ago

Ok have most of it fixed at the moment. Still looking into an edge case for batch delete!

RichardLindhout commented 4 years ago

Please try v2.0.5 it works now as far I can see! Let me know if you have any issues.

Also for the boilergql package please use latest commit like https://github.com/web-ridge/utils-go/commit/d7c1f34df76959523880e7dd81c73b4bf1d17eb7

So put d7c1f34df76959523880e7dd81c73b4bf1d17eb7 in your go.mod

github.com/web-ridge/utils-go/boilergql d7c1f34df76959523880e7dd81c73b4bf1d17eb7

And run

go mod tidy

Somehow go modules don't understand sub repositories, I need to get a better understanding of this to release these as different packages.

RichardLindhout commented 4 years ago

Let me know if I can close this issue!

RichardLindhout commented 4 years ago

Example output can be found here: https://github.com/web-ridge/gqlgen-sqlboiler-examples/blob/master/issue-12-string-ids/helpers/convert.go

troian commented 4 years ago

Will test in a moment. There is one more thing) https://github.com/web-ridge/sqlboiler-graphql-schema/issues/5

RichardLindhout commented 4 years ago

ID filter is not working at the moment for your use-case https://github.com/web-ridge/gqlgen-sqlboiler-examples/blob/master/issue-12-string-ids/helpers/filter.go#L39

Will fix that tomorrow it's the only place I think where interfaces are used so linters are not complaining there.

troian commented 4 years ago

Have this error now

error!!
validation failed: packages.Load: resolver/resolver.go:127:30: RemovedStringID not declared by package boilergql
RemovedIDsToBoilerString not declared by package boilergql
RichardLindhout commented 4 years ago

Please try v2.0.5 it works now as far I can see! Let me know if you have any issues.

Also for the boilergql package please use latest commit like web-ridge/utils-go@d7c1f34

So put d7c1f34df76959523880e7dd81c73b4bf1d17eb7 in your go.mod

github.com/web-ridge/utils-go/boilergql d7c1f34df76959523880e7dd81c73b4bf1d17eb7

And run

go mod tidy

Somehow go modules don't understand sub repositories, I need to get a better understanding of this to release these as different packages.

Yes please follow this go modules are not fixed for that package.

RichardLindhout commented 4 years ago

I'm going to sleep now :-). Nice that you're trying my package! I'm building some production concepts in it which are not released yet! Th batch update/delete calls are not tested yet but they should work. If you miss anything let me know! Also if it's already on the roadmap.

RemovedIDsToBoilerString

It's there: https://github.com/web-ridge/utils-go/blob/master/boilergql/convert.go#L43 :-D

RichardLindhout commented 4 years ago

Closed in favor of new issue: https://github.com/web-ridge/gqlgen-sqlboiler/issues/14