Control Type with goField directive #1910
Replies: 8 comments
-
Or, if there's another way of achieving this currently then I'd be very happy to hear it. |
Beta Was this translation helpful? Give feedback.
-
I've made a proposal here that would help with what you're after :) |
Beta Was this translation helpful? Give feedback.
-
I did see that but I wasn't sure it was going to help our particular case. type User {
id: ID!
}
type Account {
UserID: ID!
} What I want to be output is: type User struct {
id UserID
}
type Account struct {
UserID UserID
} |
Beta Was this translation helpful? Give feedback.
-
With my proposal that would be achieved with the following: User:
fields:
id:
fieldType: UserID
Account:
fields:
UserID:
fieldType: UserID The only caveat would be that non-native types would need to be imported (if not generated by gqlgen). If that's the case, then you'd most likely have to write: fieldType: github.com/user/repo/../mypackage.UserID |
Beta Was this translation helpful? Give feedback.
-
ok, interesting. But, I think I'd feel like I was maintaining two schemas - i.e. if I change the graphql file, I'd also have to change the config file, which is really what I'm trying to avoid. |
Beta Was this translation helpful? Give feedback.
-
Got it. Gqlgen already has YAML as an alternative to I'll let the gqlgen team handle the way forward :) |
Beta Was this translation helpful? Give feedback.
-
The current way is to manage your own struct in go and reference it in |
Beta Was this translation helpful? Give feedback.
-
My use case for this is with globally unique ids. Prefix type in id resolvers and use string in Node queries argument, everywhere else uuid with own marshaller since most places type is already known |
Beta Was this translation helpful? Give feedback.
-
Currently we have this directive....
directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
It would be useful if we could add a
type
parameter to be able to explicitly set the output Go type.e.g.
directive @goField(forceResolver: Boolean, name: String, type: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION
and can be used like
outputting...
Beta Was this translation helpful? Give feedback.
All reactions