I've already tried all the solutions I've found on stackoverflow but I still have my problem: I got a null for any REST API's call on Graphql
on my REST API's Swagger i get :
{
"_embedded": {
"marqueDtoList": [
{
"marque": "ALPINE RENAULT",
"cmarque": "AL",
"_links": {
"self": {
"href": "http://localhost:8081/demo/api-c/referentiel/marques/v1/AL"
},
"modeles": {
"href": "http://localhost:8081/demo/api-c/referentiel/marques/v1/AL/modeles",
"templated": true
}
}
},
{
"marque": "CITROEN",
"cmarque": "CI",
"_links": {
"self": {
"href": "http://localhost:8081/demo/api-c/referentiel/marques/v1/CI"
},
"modeles": {
"href": "http://localhost:8081/demo/api-c/referentiel/marques/v1/AL/modeles",
"templated": true
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:8081/demo/api-c/referentiel/marques/v1"
}
}
}
my Schema is :
type Query {
callAPI: ApiStructure
}
type ApiStructure {
_embedded : _embedded
_links : _links
}
type _embedded {
marqueDtoList : [marqueDto]
}
type marqueDto {
marque: String
cmarque: String
_links : _links
}
type _links {
self: self
modeles : modeles
}
type self {
href : String
}
type modeles {
href : String
templated : Boolean
}
and my resolvers is :
callAPI: (root, args) => {
let url = 'http://localhost:8081/demo/api-c/referentiel/marques/v1'
let options = {
method: 'GET',
headers: {
'content-type': 'application/json',
},
};
return fetch(url, options)
.then(res => (res.json()))
.then(json => JSON.stringify(json))
.then(console.log)
.catch(console.error);
}
}
when i tried my query on graphiQL, i got this
however, console gives me exactly the same result as what I get in my swagger, does anyone know why ?