-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
exec plan failed: required package was not loaded #420
Comments
It looks like you have 2 separate definitions for model: bitbucket.org/tim_online/mews-graphql/scalars.Duration and "github.com/senseyeio/duration" Are they supposed to be the same implementation? |
@mathewbyrne
|
If I change the marshalling wrapper: package scalars
import (
"errors"
"io"
"strconv"
"github.com/99designs/gqlgen/graphql"
"github.com/senseyeio/duration"
)
func MarshalDuration(d duration.Duration) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
io.WriteString(w, strconv.Quote(d.String()))
})
}
func UnmarshalDuration(v interface{}) (duration.Duration, error) {
if tmpStr, ok := v.(string); ok {
return duration.ParseISO8601(tmpStr)
}
return duration.Duration{}, errors.New("duration should be a ISO8601 formatted string")
} to: package scalars
import (
"fmt"
"io"
dur "github.com/senseyeio/duration"
)
type Duration struct {
dur.Duration
}
// UnmarshalGQL implements the graphql.Marshaler interface
func (d *Duration) UnmarshalGQL(v interface{}) error {
input, ok := v.(string)
if !ok {
return fmt.Errorf("input must be a string")
}
d2, err := dur.ParseISO8601(input)
if err == nil {
*d = Duration{d2}
}
return err
}
// MarshalGQL implements the graphql.Marshaler interface
func (d Duration) MarshalGQL(w io.Writer) {
w.Write([]byte(d.String()))
} I get no errors. |
I've created a minimal testcase here: https://github.com/omniboost/gqlgen-test $ gorunpkg github.com/99designs/gqlgen -v
exec plan failed: required package was not loaded: golang.org/x/text/language.Region |
This fixes it: progLoader := newLoader(namedTypes, true)
progLoader.Import("golang.org/x/text/language") So I believe what happens: if you're using the Marshalling wrapper methods the external struct ( |
Ah, I think this is the solution: models:
CountryCode:
# model: bitbucket.org/tim_online/mews-graphql/scalars.CountryCode
model: golang.org/x/text/language.Region |
Looks like it was my fault :( When I changed |
#2800 |
I have a custom scalar:
When running
gqlgen
I get this error:exec plan failed: required package was not loaded: github.com/senseyeio/duration.Duration
So it looks like it throws an error somewhere in
Config.buildObjects()
. Building thescalars
package works:The text was updated successfully, but these errors were encountered: