Closed yairopro closed 2 months ago
There is an easy fix for that:
Create a local graphql schema file if you don't have one and add the following line to the beginning:
clientSchema.graphql
directive @client on FIELD
Then add that client schema to your .graphqlrc.yml like that
schema:
- https://some-remote-schema.net/api/graphql
- clientSchema.graphql # <- here
documents: "src/**/*.{graphql,js,ts,jsx,tsx}"
Done
I have no .graphqlrc.yml
, I use an apollo.config.js
file. Do you know how to configure it in the same way?
You can configure it like this.
// apollo.config.js
module.exports = {
client: {
includes: [ . . . ]
service: {
name: '' // YOUR APP NAME,
localSchemaFile: './path/to/your/local/clientSchema.gql'
}
}
}
However, it wouldn't solve your problem because even though the @client
directive can be validated, the field itself is still not recognized due to it not being defined in the schema.
Hi, I'm sorry for the late answer - I'm sure you solved this in the meantime but I'll answer anyways so other people in the future can find this.
The @client
directive itself is supported, but fields you annotate with @client
still need to be defined or we will warn you about that.
To do that, you could create a extendSchemaWithClientFields.js
file somewhere in your workspace with contents like:
import gql from "graphql-tag";
gql`
extend type Shop {
logoUrl: String
}
`
With that in place, the logoUrl
field will be available and you will even get warnings if you forget to use the @client
directive with it.