阿波罗升压默认状态

时间:2018-09-05 09:52:51

标签: react-apollo apollo-client

我正在尝试创建默认状态。并进行以下设置:

export const GET_MOVIE = gql`
  query movie($id: String!){
    movie(id: $id){
      id
      title
      overview
      backdrop_path
      runtime
      vote_count
      vote_average
    }
  }
`;

这是我要发出请求的地方

export const FeaturedMovie = compose(
  graphql(GET_MOVIE, {
    props: ({ data }) => ({ data }),
    options: ownProps => ({
      variables: {
        id: `${ownProps.movie.id}`
      },
    })
  })
)(FeaturedMovieView);`

const defaults = {
  Movie: {
    __typename: 'Movie',
    Movie: 299536,
    backdrop_path: '/bOGkgRGdhrBYJSLpXaxhXVstddV.jpg',
    id: '299536',
    overview: '',
    runtime: '149',
    title: '',
    vote_average: 8.3,
    vote_count: 7600
  }
};

const client = new ApolloClient({
  uri: process.env.BASE_URL,
  clientState: {
    defaults
  }
});

常规查询没有问题。但是默认状态不起作用。

0 个答案:

没有答案