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

executor: adds support for anonymous contained structs #371

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chris-ramon
Copy link
Member

@chris-ramon chris-ramon commented Jul 28, 2018

Overview

Test plan

  • go test ./...

@imjma
Copy link

imjma commented Sep 14, 2018

HI, wondering if there is any chance to merge this?

@mrg0lden
Copy link

@chris-ramon @pavelnikolov Same question, would you please merge it?

@niondir
Copy link

niondir commented Oct 22, 2018

Same here

@chris-ramon
Copy link
Member Author

Thanks for letting us know how important this PR are for you guys.

I'll jump back to get this merge as soon as I get the chance today/tomorrow.

@coveralls
Copy link

coveralls commented Oct 24, 2018

Coverage Status

Coverage increased (+0.009%) to 91.787% when pulling d35d558 on anon-contained-struct into a7e15c0 on master.

Ariel Salomon added 2 commits October 23, 2018 19:25
@raininfall
Copy link

I think this will resolve the issue without using user-provided resolve function.

if typeField.Anonymous && typeField.Type.Kind() == reflect.Struct {
  anonymousResolvedValue, err := defaultResolveStruct(valueField, fieldName)
  if err != nil {
    return nil, err
  } else if anonymousResolvedValue != nil {
    return anonymousResolvedValue, nil
  }
}

@abraithwaite
Copy link

Just commented on the issue, but just saw this PR. I'm still interested in this!

return valueField.Interface(), nil
}
if typeField.Anonymous && typeField.Type.Kind() == reflect.Struct {
return defaultResolveStruct(valueField, fieldName)

Choose a reason for hiding this comment

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

There's a bug here. We return too early if an anonymous struct comes before a field we're looking for.

I think what we want to do is run through all the top-level fields first, then dive if the field wasn't found.
Repeat for all anonymous structs until it's found. If not found, then return nil, nil.

Choose a reason for hiding this comment

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

Here's a fix, sans a proper test:

abraithwaite@5decd5b

Choose a reason for hiding this comment

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

Good catch, @abraithwaite

@clery
Copy link

clery commented Apr 1, 2019

Any news on this ?

@cettoana
Copy link

Any updates on this PR?

@niondir
Copy link

niondir commented Jun 13, 2019

Still waiting for the merge as qell...

@pavelnikolov
Copy link

pavelnikolov commented Jun 13, 2019

This PR has conflicts.

@SuNNjek
Copy link

SuNNjek commented Aug 26, 2020

Is this still being worked on?

@pavelnikolov
Copy link

Not that I am aware of

@bakatest-me
Copy link

bakatest-me commented Jun 23, 2022

Hi
how to use this feature on graphq-go/graphql v0.8.0 (master branch)?
about Anonymous(embed) struct

@taleeus
Copy link

taleeus commented Mar 20, 2024

Bump

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.

Issue with embedded Struct response