GraphQL-查询并将结果传递给下一个查询并合并数据?

时间:2020-09-29 22:19:48

标签: graphql gatsby graphql-js

是否可以运行查询然后获取结果,将其用作参数以进一步获取数据,然后像联合一样将其组合到结果集中?我想从prismicHeaderMenu中获取标签,然后获取我的Shopify产品信息,然后合并所有数据。 GraphQL有可能吗?

enter image description here


import Foundation
import Combine
import Firebase

class SessionStore: ObservableObject {
    
    @Published var isLoggedIn: Bool = UserDefaults.standard.bool(forKey: "isLoggedIn") {
        didSet {
            UserDefaults.standard.set(self.isLoggedIn, forKey: "isLoggedIn")
        }
    }

    var userSession: User?
    
    var handle: AuthStateDidChangeListenerHandle?
    
    func listenAuthenticationState() {
        handle = Auth.auth().addStateDidChangeListener({ (auth, user) in
            if let user = user {
                print(user.email as Any)
                let firestoreUserId = Ref.FIRESTORE_DOCUMENT_USERID(userId: user.uid)
                firestoreUserId.getDocument { (document, error) in
                    if let dict = document?.data() {
                        guard let decodeUser = try? User.init(fromDictionary: dict) else { return }
                        self.userSession = decodeUser
                    }
                }
                self.isLoggedIn = true
            } else {
                print("User is Logged Out")
                self.isLoggedIn = false
                self.userSession = nil
            }
        })
    }
}

0 个答案:

没有答案