我有一个工作web graphql查询:
{
me{
... on Student{
profile {
fullName
emailId
mobileNumber
civilId
address
city
state
country
zipCode
userProfilePic
userCategory
createdAt
updatedAt
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它返回特定学生的个人资料详细信息.我使用变异记录并获取用户的令牌.
我想创建一个graphql文件(例如StudentProfile.graphql),以便使用Apollo客户端进行获取请求(类似于http.get).
我提出此请求以获取graphql查询.
func fetchStudentProfileDetails(){
let tokenString = "Bearer " + "....my token ..."
print(tokenString)
let newApollo: ApolloClient = {
let configuration = URLSessionConfiguration.default
// Add additional headers as needed
configuration.httpAdditionalHeaders = ["Authorization": tokenString]
let url = URL(string: "http://52.88.217.19/graphql")!
return ApolloClient(networkTransport: HTTPNetworkTransport(url: url, configuration: configuration))
}()
newApollo.fetch(query: StudentProfileQuery()) { (result, error) in
self.profileDetailsTextView.text = …Run Code Online (Sandbox Code Playgroud)