I'm migrating some services from Rest to Graphql in an Ionic App. I use the Ionic/Cordova native http plugin in order to make requests to my server, in the following way:
import {HTTP} from '@ionic-native/http/ngx'
@Injectable()
export class ApiProvider {
private server = "https://api.myserver.com/'
constructor(
private nativeHttp:HTTP
)
{}
getData(path:string,params = "")
{
const url = this.server + path + params
return this.nativeHttp.get(url,{},{
'Content-Type':'application/json'
})
}
}
My question is: How can I pass a graphql query in it? I've tried making the full url look like this https://api.myserver.com/graphql?query={people{id,name}}
but I got the following error from graphql:
{
"errors": [
{
"message": "Unknown operation named \"IntrospectionQuery\"."
}
]
}
which differs from the successful result that I get in Postman for the exact same url.
How can I make this query using the http plugin?
Thank you in beforehand!