Comments (11)
introspection?
from cynic.
@jxnu-liguobin graphql servers support "introspection queries": https://graphql.org/learn/introspection/ which let you ask a server about it's schema. You can build up a schema from these, which cynic could use instead of a schema on the filesystem like it uses currently.
Although cynic would first need to support introspection queries, as it doesn't currently.
from cynic.
@obmarg Yes, I'll think about it and see if I can make it.
I think we can continue to use schema_ path
property to set the introspection server address.
from cynic.
@obmarg Hi,
So, what I want to do is to implement a similar function load_schema_from_server
?
Here, suppose we use the HTTP URL
setting schema_path
, every derive macro needs to read schema_path
when using introspection, it may need to add a layer of cache here to avoid the acquisition failure and efficiency problems.
from cynic.
Yeah, that is roughly what you'd want.
Indeed a cache would be good - would definitely like to avoid running an introspection query for every single derive.
from cynic.
@obmarg
Since introspection itself is also a graphql, we need graphql query, and we may need a config similar to schema_path
.
How to configure this? Or the schema_path
change path to a struct(I'm not sure I can do that).
(the introspection results can refer to the introspection decoding implementation of graphql-client
, or directly introduce it .(it's really not good))
from cynic.
Sorry for the delay getting back to you @jxnu-liguobin - I've not had any time to pay attention to cynic the past couple of weeks.
You're correct that we will need an introspection query implementation to do this. I've got a WIP cynic implementation of one sitting on my machine (I was looking into doing this a couple of months ago, but got distracted by other bits). I've uploaded it to this branch if you want to have a look. I can't remember what needed fixed in it - it may be easy or may be some missing feature in cynic that we need in order to finish it off.
As for how to configure this: I am not entirely sure. Given that we probably don't want to make a request for every derive and GraphQL servers can sometimes require authentication or other configuration I'm not sure it even makes sense to update the derives to make an introspection query. The number of options we'd need to support is quite large, and caching might be difficult.
Maybe it makes more sense to provide users the ability to run an introspection query and output a schema.graphql file from that. Then users can write a build.rs
or similar to fetch their query using the functionality we provide, and the derives can just read the schema.graphql that outputs. Seems like it might be a lot easier to implement things that way.
from cynic.
Maybe it makes more sense to provide users the ability to run an introspection query and output a schema.graphql file from that. Then users can write a
build.rs
or similar to fetch their query using the functionality we provide, and the derives can just read the schema.graphql that outputs. Seems like it might be a lot easier to implement things that way.
Yes, it will be easier.
You're correct that we will need an introspection query implementation to do this. I've got a WIP cynic implementation of one sitting on my machine (I was looking into doing this a couple of months ago, but got distracted by other bits). I've uploaded it to this branch if you want to have a look. I can't remember what needed fixed in it - it may be easy or may be some missing feature in cynic that we need in order to finish it off.
It looks like only the structure is defined, which looks fine if the user writes the low-level API himself(users need write build.rs to executes graphql query).
from cynic.
It looks like only the structure is defined, which looks fine if the user writes the low-level API himself(users need write build.rs to executes graphql query).
Yeah, I only got as far as writing the structure of an introspection query. We'll also need to write the code that converts the results of an introspection query into a schema.
I'd probably let users write the actual HTTP call & output of the schema themselves. It's not too hard to do, and there's a fairly wide variety of ways to do it: different HTTP clients, different authentication schemes etc. so be quite hard to cover all the possibilities. Can provide some examples in the repository that users can use as a starting point.
from cynic.
👌
from cynic.
Between cynic-introspection
& cynic-cli
this is now supported. It's not fully documented, but I wouldn't recommend this approach for most users anyway.
A smart user who wants to go against my recommendation should hopefully be able to figure it out for themselves.
from cynic.
Related Issues (20)
- Flatten doesn't like `Option<Vec<Option<String>>>` HOT 1
- `cynic generate` improvements HOT 1
- `cynic author`
- cynic-parser tracking issue
- GraphQlResponse Clonable? HOT 4
- cynic-introspection SDL is missing directives
- Fix default root handling in cynic-codegen HOT 1
- Object in array in arguments attribute fails to compile
- Catch unintentionally recursive structs at compile time HOT 8
- Fully fledged example for working with Large APIs HOT 2
- Macro with generator.cynic-rs.dev functionality HOT 5
- Vec<String> variables or arguments not being passed correctly in when I upgrade from v1.0 to cynic v3.4.3 HOT 3
- Update reqwest to 0.12 HOT 5
- reinstate cli builds as part of releases
- Deprecate & remove pre 2.0.0 argument syntax
- Put spans on things somehow HOT 1
- admonishments in the book are broken
- Cannot retrieve `GraphQLResponse`s with `ErrorExtensions` properly HOT 4
- Dependency Dashboard
- Action Required: Fix Renovate Configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cynic.