what's the use of `fetch_schema_from_transport` flag
Closed this issue · 3 comments
Having this flag as true
adds a huge instantiation overhead over the gql.Client
In the docs isn't clear what's the actual difference between having this flag as true
or false
.
So my question is: What's the difference between having this flag or not?
I understand it's a boolean to indicate if we want to fetch the schema from the transport using an introspection query. But why/how is this useful at all?
If a schema is available, gql will validate the queries locally before sending them to the backend.
This is explained in the schema validation part of the docs.
You'll also need a schema:
If you don't want to validate your queries and don't need those two features, then no schema is needed.
Using introspection with fetch_schema_from_transport=True
can be useful during development when the schema of the backend changes a lot as it ensures that the client always have the latest schema available. Once you're in production, if you need a schema for the reasons above, then you're better to just download the schema and provide it as a file in your client.
Feel free to propose a PR to make the docs clearer about this.
Thanks for the explanation @leszekhanusz
I wonder what is the advantage of locally validating the queries?
I just made some tests to test the validation, and it seems the exceptions raised for invalid queries are the same while validating the schema or not.
I wonder what is the advantage of locally validating the queries?
Not much, I agree
I just made some tests to test the validation, and it seems the exceptions raised for invalid queries are the same while validating the schema or not.
Normally you should receive a GraphQLError
if the validation is done locally and a TransportQueryError
if the validation is done by the backend.