Comments (3)
Could you paste the JSON documents you request, please?
from vulcain.
Hi @dunglas
Thanks for your time!
This is a screen of my output greetings
And the author
I tried more since my last post, it seems to work if Fields header match between author et greetings, what i mean, if for my get of authors/1 i've this:
.then(() => window.fetch('https://localhost/authors/1', {
headers: {
fields: '"/@id"'
}
})
I see this with query parameters example, so i thinks i should reporter "/hydra:member/*/author/@id" to /@id when i fetch him. Isn't it? So, why not, it works!
However, I don't know how to make work with a new level after (in my exemple, authors have comments)
So, i tried:
window.fetch('https://localhost/greetings?'/*+encodeURI('fields="/hydra:member/!*!/@id"&fields="/hydra:member/!*!/name"&fields="/hydra:member/!*!/author/firstName"')*/, {
headers: {
preload: '"/hydra:member/*/author/comments/*"',
fields: '"/hydra:member/*/@id", "/hydra:member/*/name", "/hydra:member/*/author/@id", "/hydra:member/*/author/firstName", "/hydra:member/*/author/comments/*/@id"'
}
}).then(() => window.fetch('https://localhost/authors/1', {
headers: {
fields: '"/@id", "/firstName"'
}
}).then(() => window.fetch('https://localhost/comments/1', {
headers: {
fields: '"/@id"'
}
}))
)
Good fields are displayed
but, no push...
I tried many case, but either i've good fields or push but never both :'(
I saw this syntax in your demo symfo repo:
const conferences = await fetchJson('/conferences', { headers: { Preload: "/hydra:member/*/@id/sessions/*/feedback/*" }});
I don't understand this syntax with the @id before sessions, but when i tried, all my next calls are push but without fields....
Do you have a full example somewhere with multi level and fields headers?
Thanks
from vulcain.
Hi @dunglas ,
sorry to come back, i know you're busy.
Just, do you know if is it possible to combine Fields and Preload to a nested level of relationship with current version of Vulcain?! Or i miss something that i misunderstand
Push is stopped after 1st level if i add fields (if i comment adding Fields all is pushed but without picked fields)
My last js script with query mode :
let url = 'https://localhost/greetings?'
// url += encodeURI('preload="/hydra:member/*/@id/author/comments/*"')
// url += encodeURI('preload="/hydra:member/*/author/comments/*"')
url += encodeURI('preload="/hydra:member/*/author"&preload="/hydra:member/*/author/comments/*"')
url += encodeURI('&fields="/hydra:member/*/@id"&fields="/hydra:member/*/name"&fields="/hydra:member/*/author/@id"&fields="/hydra:member/*/author/firstName"&fields="/hydra:member/*/author/comments/*/@id"')
// url += encodeURI('&fields="/hydra:member/*/@id"&fields="/hydra:member/*/name"&fields="/hydra:member/*/author/firstName"&fields="/hydra:member/*/author/comments/*/@id"')
// url += encodeURI('fields="/hydra:member/*/@id"&fields="/hydra:member/*/name"')
window.fetch(url).then(async (response) => {
const json = await response.json()
const greetings = json['hydra:member']
window.fetch(greetings[0]['author'])
.then(async(reponse2) => {
const author = await reponse2.json()
window.fetch(author.comments[0])
})
}
)
My greetings collection:
{
"hydra:member": [
{
"author": "/authors/1?fields=%22%2Fcomments%2F%2A%2F%40id%22%2C+%22%2F%40id%22%2C+%22%2FfirstName%22",
"@id": "/greetings/1",
"name": "TestABC"
},
{
"author": "/authors/1?fields=%22%2Fcomments%2F%2A%2F%40id%22%2C+%22%2F%40id%22%2C+%22%2FfirstName%22",
"@id": "/greetings/7",
"name": "AAA"
},
{
"author": "/authors/1?fields=%22%2Fcomments%2F%2A%2F%40id%22%2C+%22%2F%40id%22%2C+%22%2FfirstName%22",
"@id": "/greetings/8",
"name": "fdgfdg"
},
{
"author": "/authors/1?fields=%22%2Fcomments%2F%2A%2F%40id%22%2C+%22%2F%40id%22%2C+%22%2FfirstName%22",
"@id": "/greetings/9",
"name": "CCC"
},
{
"author": "/authors/1?fields=%22%2Fcomments%2F%2A%2F%40id%22%2C+%22%2F%40id%22%2C+%22%2FfirstName%22",
"@id": "/greetings/10",
"name": "123456"
}
]
}
My author (pushed)
{
"comments": [
"/comments/1?fields=%22%2F%40id%22"
],
"@id": "/authors/1",
"firstName": "BenWa"
}
My comment (not push but good fields)
{
"@id": "/comments/1"
}
Thanks for your time.
BenWa
from vulcain.
Related Issues (20)
- Package deleted: https://github.com/dunglas/vulcain/caddy HOT 6
- Regression since 0.4.1 HOT 3
- Vulcain does not work "out of the box" with API Platform HOT 3
- Cannot tag Vulcain in Stackoverflow HOT 2
- integration: html - https://htmx.org/examples/ HOT 1
- Http,2,3 vulcain
- Flaky test
- Stateless authorization on preload requests
- Mistagged caddy module? HOT 6
- [Question] Can i use FrankenPHP with Vulcain and cache-handler in single Caddy process?
- Curren state HOT 2
- Preload link should include the "crossorigin" attribute, if initial request uses CORS
- Link Varnish X-Key broken HOT 1
- Aucun preload ne fonctionne HOT 2
- Unable to decode with compressed response from origin HOT 1
- Preload only working on localhost HOT 1
- Request made by the browser does not contain the "authorization" header
- Response's body is percent encoded when parametrized queries HOT 1
- Re-add Server Push tests
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 vulcain.