facebook / facebook/relay

[Modern] Query only the local client extension types will cause compiling error

Open
#2,471 35 comments 5 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Let's say I declare the client schema extensions

client.graphql
``` graphql
type Token {
accessToken: String
refreshToken: String
}

extend type Query {
token: Token
}
```

And then in the QueryRenderer I made the query like this

```graphql
query RootQuery {
token {
accessToken
refreshToken
}
}
```

The `relay-compiler` will fire the error
```
GraphQLCompilerContext: Unknown document `RootQuery`.
```

My temporary workaround is adding extra fields that can be fetched from remote.
```graphql
query RootQuery {
viewer {
me {
id
}
}
token {
accessToken
refreshToken
}
}
```

In this way, compiler can successfully compile the static query.

My assumption is `relay-compiler` will remove whatever client extensions from the query string, if I only query the local type, the query string will be stripped out entirely.

My question is "Is it possible for relay to query **ONLY** the local type?" People like me are excited about the client extensions is because it gives a way to get rid of the redux store. It will be really helpful if we can directly query the local type and use commitLocalUpdate for the state management.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.