Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Logging Apollo GraphQL和React等效于redux记录器_Logging_Graphql_React Apollo_Apollo Client - Fatal编程技术网

Logging Apollo GraphQL和React等效于redux记录器

Logging Apollo GraphQL和React等效于redux记录器,logging,graphql,react-apollo,apollo-client,Logging,Graphql,React Apollo,Apollo Client,我正在学习graphql,想知道阿波罗客户端是否有日志记录解决方案 我发现redux logger是调试React/redux应用程序的绝佳工具,我想知道appolo客户端是否存在类似的东西 我想随时查看我的存储的状态。好吧,我想我应该多研究一下 这里有很好的解释: 如果有人对它感兴趣,这就是我如何使用redux logger实现apollo客户端的方法 import React from 'react'; import { createStore, combineReducers, apply

我正在学习
graphql
,想知道阿波罗客户端是否有日志记录解决方案

我发现
redux logger
是调试React/redux应用程序的绝佳工具,我想知道
appolo客户端是否存在类似的东西


我想随时查看我的
存储的状态。

好吧,我想我应该多研究一下

这里有很好的解释:

如果有人对它感兴趣,这就是我如何使用
redux logger
实现
apollo客户端的方法

import React from 'react';
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import createLogger from 'redux-logger';
import promise from 'redux-promise';
import ReactDOM from 'react-dom';
import  ApolloCient from 'apollo-client';
import { ApolloProvider } from 'react-apollo';
import reducers from './reducers';

import App from './App';

// Instantiate Apollo Client
const client = new ApolloCient();

// declare the redux-logger
const logger = createLogger({
  collapsed: true,
  diff: true,
});

const store = createStore(
  combineReducers({
    apollo: client.reducer(), // apollo reducer
    reducers, // your others reducers
  }),
  {},
  compose(
    // apply client.middleware() from ApolloClient and logger from redux-logger
    applyMiddleware(client.middleware(), thunk, promise, logger),

    // If you are using the devToolsExtension, you can add it here also
    // window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
  )
);


const Root = () => {
  return (
    // pass redux store and apollo client to ApolloProvider
    <ApolloProvider store={store} client={client}>
      <App />
    </ApolloProvider>
  );
};

ReactDOM.render(
  <Root />,
  document.querySelector('#root')
);
从“React”导入React;
从'redux'导入{createStore,combinereducer,applyMiddleware,compose};
从“redux thunk”导入thunk;
从“redux logger”导入createLogger;
从“redux承诺”进口承诺;
从“react dom”导入react dom;
从“apollo客户端”导入ApolloCient;
从'react apollo'导入{ApolloProvider};
从“./reducers”导入减速机;
从“./App”导入应用程序;
//实例化Apollo客户端
const client=new ApolloCient();
//声明redux记录器
const logger=createLogger({
对,,
没错,
});
const store=createStore(
组合传感器({
apollo:client.reducer(),//apollo reducer
减速机,//您的其他减速机
}),
{},
谱写(
//应用ApolloClient中的client.middleware()和redux logger中的logger
applyMiddleware(client.middleware()、thunk、promise、logger),
//如果您使用的是devToolsExtension,也可以将其添加到此处
//window.\uuuu REDUX\u DEVTOOLS\u EXTENSION\uuux&&window.\uuuu REDUX\u DEVTOOLS\u EXTENSION\uuux(),
)
);
常量根=()=>{
返回(
//将redux商店和apollo客户端传递给apollo提供商
);
};
ReactDOM.render(
,
document.querySelector(“#root”)
);