反应,aws appsync,阿波罗连接/查询-GraphQL错误:执行超时

时间:2019-02-25 12:06:44

标签: reactjs apollo aws-appsync aws-amplify

嗨,我正在尝试连接和查询来自AWS Appsync服务器的数据,并且总是要加载几分钟,然后出现 GraphQL错误:执行超时

我尝试了几种方法,但总会导致无限加载。

连接:

Amplify.configure({
    Auth: {
        identityPoolId: config.awsmobile.aws_cognito_identity_pool_id,
        region: config.awsmobile.aws_cognito_region,
        userPoolId: config.awsmobile.aws_user_pools_id,
        userPoolWebClientId: config.awsmobile.aws_user_pools_web_client_id
    }
});


export const client = new AWSAppSyncClient({
    url: config.awsmobile.aws_appsync_graphqlEndpoint,
    region: config.awsmobile.aws_appsync_region,
    auth: {
        type: AUTH_TYPE.AWS_IAM,
        credentials: () => Auth.currentCredentials()
    }
});


export default class App extends Component {
    render() {
        return (
            <div>
                <ApolloProvider client={client}>
                    <Home/>
                </ApolloProvider>
            </div>
        );
    }
}

查询:

export default class Home extends React.Component {
    render() {
        return (
            <Query variables={{bookCode: "GEN"}} query={gql(query)}>
                {({loading, error, data}) => {
                    if (loading) return (
                        <div className="loading">Loading&#8230;</div>
                    );
                    if (error) return <h1>{console.log(error)}Error :(</h1>;

                    console.log(data);

                    return (<h1>Nice</h1>)
                }}
            </Query>
        )
    }
}

错误:

GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL error: Execution timed out. GraphQL erroApolloError.js:58)
    at ObservableQuery.currentResult (ObservableQuery.js:125)
    at Query._this.getQueryResult (react-apollo.browser.umd.js:456)
    at finish (react-apollo.browser.umd.js:635)
    at Query.render (react-apollo.browser.umd.js:642)
    at finishClassComponent (react-dom.development.js:15121)
    at updateClassComponent (react-dom.development.js:15076)
    at beginWork (react-dom.development.js:16066)
    at performUnitOfWork (react-dom.development.js:20086)
    at workLoop (react-dom.development.js:20127)
    at renderRoot (react-dom.development.js:20207)
    at performWorkOnRoot (react-dom.development.js:21164)
    at performWork (react-dom.development.js:21074)
    at performSyncWork (react-dom.development.js:21048)
    at requestWork (react-dom.development.js:20903)
    at scheduleWork (react-dom.development.js:20716)
    at Object.enqueueForceUpdate (react-dom.development.js:11605)
    at Query.Component.forceUpdate (react.development.js:355)
    at Query._this.updateCurrentData (react-apollo.browser.umd.js:440)
    at Object.error (react-apollo.browser.umd.js:426)
    at notifySubscription (Observable.js:157)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.error (Observable.js:253)
    at eval (ObservableQuery.js:432)
    at Array.forEach (<anonymous>)
    at Object.error (ObservableQuery.js:431)
    at eval (QueryManager.js:530)
    at eval (QueryManager.js:982)
    at Array.forEach (<anonymous>)
    at eval (QueryManager.js:981)
    at Map.forEach (<anonymous>)
    at QueryManager.broadcastQueries (QueryManager.js:977)
    at Object.next (QueryManager.js:1060)
    at notifySubscription (Observable.js:152)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.next (Observable.js:248)
    at eval (bundle.esm.js:98)
    at Array.forEach (<anonymous>)
    at Object.next (bundle.esm.js:97)
    at notifySubscription (Observable.js:152)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.next (Observable.js:248)
    at notifySubscription (Observable.js:152)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.next (Observable.js:248)
    at notifySubscription (Observable.js:152)
    at onNotify (Observable.js:196)
    at SubscriptionObserver.next (Observable.js:248)
    at notifySubscription (Observable.js:152)
    at onNotify (Observable.js:196)

我做了另一种方式,这几乎是相似的,如果有必要,我稍后会提供代码

0 个答案:

没有答案