Comments (3)
Hi @miko, thanks for filing this.
Do you have a specific use for accessing GraphQL datasources with gomplate?
One particular problem with GraphQL (as opposed to more traditional RESTful APIs) is the somewhat complex request body necessary to make almost any query. With a RESTful API, you can treat the remote endpoint like a filesystem, where the GET
method is conceptually similar to a regular read operation. But with GraphQL, all queries (as far as I know?) are POST
s, and require bodies. I'm not sure how it would be possible to model that as a datasource in URL form, which is a strict necessity for gomplate.
Does this make sense, or am I missing some obvious simpler usage here?
from gomplate.
GraphQL queries can be transmitted by HTTP either as POST or GET request, as specified here:
https://graphql.org/learn/serving-over-http/
There are (read-only) queries and (possibly read-write) mutations (add, update, delete), so I mean queries as datasources (both by GET or POST).
Example graphql query using GET:
curl -v 'https://countries.trevorblades.com/graphql?query=\{countries\{name\}\}'
(but some graphql servers may block the GET method, even if required by specifiaction)
Example graphql query using POST:
curl --request POST \
--header 'content-type: application/json' \
--url 'https://spacex-production.up.railway.app/' \
--data '{"query":"query ExampleQuery($limit: Int) {\nships (limit:$limit){\n name\n}\n}","variables":{"limit":2}}'
For simple cases (like the first query above) you could use a http datasource, but the real help would be if for the second case I could use something similar to:
gomplate -d foo=graphql+POST://spacex-production.up.railway.app/' --query '{ships (limit:$limit){name}}' --variables '{"limit":2}'
gomplate -d foo=graphql+POST://spacex-production.up.railway.app/' --queryfile ./ships.graphql --variables '{"limit":2}'
from gomplate.
Thanks for the response @miko. Like I said above, this would be a significant departure from how gomplate works with datasources today. Datasources are modelled internally as filesystems accessed purely through URLs, and so passing in a large query body and set of variables seems like it just wouldn't work conceptually.
Being a query language, GraphQL is much more akin to SQL (which gomplate also can't support) than a filesystem layer on top of a key-value storage back-end.
As such, I think the answer this feature is going to have to be "no" (at least, not yet).
I'm going to close the issue, but feel free to comment further, or start up a discussion if you can see a reasonable approach that could fit elegantly within gomplate's operational model.
from gomplate.
Related Issues (20)
- Cannot install in GitHub Actions using go install HOT 8
- `file.Write` doesn't respect outputDir HOT 7
- gomplate produces no result and no error HOT 1
- Need to finalize gomplate.Renderer and related types before v4.0.0 HOT 2
- Tests failing on 32-bit builds due to unaligned struct in dependency HOT 5
- Provide TrimLeft and TrimRight Support HOT 8
- Process datasources as templates before the final template
- SQL datasource HOT 3
- bug: can't retrieve from Vault KVv2 mounts with slashes in the name HOT 6
- Release `aarch64` artifact HOT 1
- vault aws iam auth support/documentation
- aws sm and smp datasources fail on EC2 instance HOT 3
- plugin function is executed within an if block that evaluates to false HOT 5
- Is the second example for `coll.Merge` incorrect?
- OS information... HOT 1
- Secrets Manager Datasource Doesn't Appear to Work HOT 3
- Turn off following symlinks HOT 3
- Handling generic path type with versioning in Vault HOT 1
- Update Go version to 1.22.5 due to CVE-2024-24791
- `excludeProcessing` does not obey negative patterns
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 gomplate.