Gqlgen: panic: DateTime was not found

Created on 4 Mar 2019  路  8Comments  路  Source: 99designs/gqlgen

Expected Behaviour

Can generate code and resolver from schema.graphql

Actual Behavior

panic: DateTime was not found

goroutine 1 [running]:
ws/gqlqs/vendor/github.com/99designs/gqlgen/codegen.(*builder).bindField.func1(0xc0009a1d40, 0xc0007c7960)
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/codegen/field.go:81 +0xac
ws/gqlqs/vendor/github.com/99designs/gqlgen/codegen.(*builder).bindField(0xc0007c7960, 0xc00043c800, 0xc0009a1d40, 0x16cc180, 0xc000455ee0)
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/codegen/field.go:168 +0xbd6
ws/gqlqs/vendor/github.com/99designs/gqlgen/codegen.(*builder).buildField(0xc0007c7960, 0xc00043c800, 0xc00019d7a0, 0xc0009a1c00, 0x0, 0x0)
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/codegen/field.go:64 +0x31d
ws/gqlqs/vendor/github.com/99designs/gqlgen/codegen.(*builder).buildObject(0xc0007c7960, 0xc0000e7c80, 0x15ef4c0, 0x6, 0x0)
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/codegen/object.go:72 +0x4d4
ws/gqlqs/vendor/github.com/99designs/gqlgen/codegen.BuildData(0xc0001e40c0, 0x16cca00, 0x1acd4a0, 0x0)
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/codegen/data.go:76 +0x395
ws/gqlqs/vendor/github.com/99designs/gqlgen/api.Generate(0xc0001e40c0, 0x0, 0x0, 0x0, 0x0, 0x162fef8)
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/api/generate.go:37 +0x22d
ws/gqlqs/vendor/github.com/99designs/gqlgen/cmd.glob..func1(0xc0001ec000)
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/cmd/gen.go:39 +0xa2
ws/gqlqs/vendor/github.com/urfave/cli.HandleAction(0x152f7a0, 0x16302f8, 0xc0001ec000, 0xc0001163c0, 0x0)
    /Users/gtm/go/src/ws/gland/vendor/github.com/urfave/cli/app.go:492 +0x7c
ws/gqlqs/vendor/github.com/urfave/cli.(*App).Run(0xc0001e0000, 0xc000020020, 0x1, 0x1, 0x0, 0x0)
    /Users/gtm/go/src/ws/gland/vendor/github.com/urfave/cli/app.go:264 +0x57c
ws/gqlqs/vendor/github.com/99designs/gqlgen/cmd.Execute()
    /Users/gtm/go/src/ws/gland/vendor/github.com/99designs/gqlgen/cmd/root.go:40 +0x224
main.main()
    /Users/gtm/go/src/ws/gland/scripts/gqlgen.go:8 +0x20
exit status 2

Minimal graphql.schema and models to reproduce

type Query {
  countries: [Country!]!
}

type Mutation {
  createCountry(input: CountryCreateInput!): Country
}

# input
input CountryCreateInput {
  name: String!
  code: String!
}

scalar DateTime
scalar Json

type Country {
  name: String!
  code: String!
  images: [Json!]!
  createdAt: DateTime!
}

bug v0.8.1

Most helpful comment

Why did you close this? This is still an issue that needs to be fixed - it just has a workaround. The same schema in 0.7 doesn't work in 0.8

All 8 comments

I'm experienced same issue, but with usual types, for example Country from example above. Used dep to add that dependency and yes it is v0.8.0
My schema is more complex and it fails randomly at different types. v0.7.2 works great with the same exact schema.

Adding the custom scalar type in gqlgen.yml models fixed the problem for me.

thank you.

Why did you close this? This is still an issue that needs to be fixed - it just has a workaround. The same schema in 0.7 doesn't work in 0.8

I'm ok with @Dispersia.

This is a regression. No?

@Dispersia Sorry, I've reopened it. It also same error with Json or (non builtin scalar type)

@atomicleads

My schema is more complex and it fails randomly at different types. v0.7.2 works great with the same exact schema.

This sounds like a separate issue?

Was this page helpful?
0 / 5 - 0 ratings