-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Generated code imports own package (import cycle) #143
Comments
a simple schema to reproduce the bug: input Filter {
offset: Int!
limit: Int!
}
type Todo {
id: String!
text: String!
author: User!
# the default value cause the import cycle error
events(filter: Filter = {offset: 0, limit: 25}): [Event!]!
} |
@z0mbie42 i filled in some of the missing items i see a interesting bug with Filter. input Filter {
offset: Int!
limit: Int!
}
type Todo {
id: String!
text: String!
author: User!
# the default value cause a bug
events(filter: Filter = {offset: 0, limit: 25}): [Event!]!
}
type User {
name: String!
}
type Event {
name: String!
}
type Query {
todos: [Todo!]!
} generates the following:
there is a missing comma between the offset and limit. |
Thanks for the defaults fix. The import loop is less obvious, most of the examples work the way you're describing. eg https://github.com/vektah/gqlgen/blob/master/example/scalars/types.json#L2 I wonder if this is another case sensitivity issue, what OS are you running? Have you tried since #136? A more complete example would be handy here. |
The simpler way to reproduce the error is using the following project: events(filter: Filter): [Event!]! by events(filter: Filter = {offset: 0, limit: 25}): [Event!]! But, after applying the patch #146 the code generate without error (no missing comma and no import cycle) |
There may be a way to avoid this using the
package
andmodelpackage
flags, but it isn't obvious to me.My situation is I'm generating in the
foo/bar/model
package, and types.json includes"Form": "foo/bar/model.Form"
Expected Behaviour
Generator recognizes this is the destination package, does not attempt import.
Actual Behavior
generated.go includes import line:
"foo/bar/model"
resulting in import cycle.The text was updated successfully, but these errors were encountered: