ardatan / ardatan/graphql-import

When using the "extend" keyword only, types aren't automatically imported

Open
#589 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
No language data
Stars
864
Forks
53
PR merge metrics
No merged PRs in 30d

Description

Hey,

When using `extend` with a type, if it isn't anywhere in the schema without `extend`, input and return types used in its fields and the type itself aren't in the final schema unless explicitly imported.

This is a problem in federated services which sometimes only extend certain types.

```graphql
# query.graphql
extend type Query {
test: Test
}

type Test {
ok: Boolean
}
```

```graphql
# schema.graphql

# import Query from "query.graphql"
```

schema after importing `schema.graphql` (`Test` is absent):
```graphql
extend type Query {
test: Test!
}
```

Adding `type Query { anyField: AnyType }` anywhere produces a valid schema, but also drops the `extend` keyword

Other import methods:
```graphql
# import Query.* from "query.graphql"
```
Same result

```graphql
# import "query.graphql"
# import * from "query.graphql"
```
The `Query` type is not present at all (so in the exemple, it throws because it's an empty schema)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the query.graphql and schema.graphql examples, then trace how importing an extend-only Query definition builds the final schema. Done means the imported schema retains Query, Test, and the field's input and return types without requiring an unrelated non-extended definition.

Written by the indexing model from the issue text.

Assessment

Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.