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

entgql: use goModel directive for mapping #247

Merged
merged 1 commit into from
Mar 6, 2022
Merged

entgql: use goModel directive for mapping #247

merged 1 commit into from
Mar 6, 2022

Conversation

a8m
Copy link
Member

@a8m a8m commented Mar 6, 2022

In case the GraphQL node name is different from the Ent name, autobind won't work, and we need to map it explicitly.

@a8m a8m requested a review from giautm March 6, 2022 06:41
@a8m a8m force-pushed the gqldirective branch 2 times, most recently from 80a3754 to f605e3d Compare March 6, 2022 06:44
directives = map[string]*ast.DirectiveDefinition{
"goModel": {
Name: "goModel",
Position: pos,
Copy link
Collaborator

Choose a reason for hiding this comment

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

position can be set to nil

Copy link
Member Author

Choose a reason for hiding this comment

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

It's needed here, but not in other places.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x150c2c2]

goroutine 1 [running]:
github.com/vektah/gqlparser/v2/formatter.(*formatter).FormatDirectiveDefinition(0x15a7f60, 0xc000347a40)

https://github.com/vektah/gqlparser/blob/master/formatter/formatter.go#L326-L328

@a8m a8m force-pushed the gqldirective branch 4 times, most recently from 093d839 to 5b4f311 Compare March 6, 2022 07:47
In case the GraphQL node name is different than Ent name,
autobind won't work, and we need to map it explicitly.
Copy link
Collaborator

@giautm giautm left a comment

Choose a reason for hiding this comment

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

LGTM

@giautm
Copy link
Collaborator

giautm commented Mar 6, 2022

How to mapping the custom type CategoryConfig to GoType with the goModel directive?

@a8m
Copy link
Member Author

a8m commented Mar 6, 2022

How to mapping the custom type CategoryConfig to GoType with the goModel directive?

I'll map fields with custom GoType in a different PR.

@a8m a8m merged commit 0bd2cb6 into master Mar 6, 2022
@a8m a8m deleted the gqldirective branch March 6, 2022 12:52
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.

2 participants