(Federation) Models and executable schema can't exist in different packages
- Vorherrschende Sprache
- Go
- Sterne
- 10.8k
- Forks
- 1.3k
- Ø Merge
- 2 T. 36 Min.
- Gemergte PRs (30 T.)
- 26
Beschreibung
### What happened?
Trying out federation, the executable schema couldn't make use of the models if they were in a different package.
Using a config like:
```yaml
schema:
- schema.graphql
exec:
filename: generated/executableschema.go
model:
filename: models/models.go
resolver:
filename: resolver/resolver.go
type: Resolver
federated: true
autobind: []
```
It produced a model like
```go
type _Entity interface {
Is_Entity()
}
```
Which, not starting with a capital meant package generated couldn't use it from package models, with some of that code looking like
```go
res := resTmp.([]models._Entity) // <--- the issue
fc.Result = res
return ec.marshalN_Entity2ᚕgithubᚗcomᚋzerbitxᚋgapiᚋmodelsᚐ_Entity(ctx, field.Selections, res)
```
### What did you expect?
The Apollo federation extra bits to be added like service/_entities etc, and everything to generally work the same as before adding `federated: true`
### Minimal graphql.schema and models to reproduce
```graphql
type Whatevs @key(fields: "id") {
id: ID!
}
```
### versions
- `gqlgen version`?
v0.10.2-dev
- `go version`?
1.13.4
- dep or go modules?
modules
### Easy Workaround
Keep the model and exec in the same package
### Thanks
Thank you @marwan-at-work I'm very grateful for your efforts here.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.