Search code examples
javascriptreactjsgraphqlmutation

How to push a graphql mutation into a component's props properly?


I'm trying to push a graphql mutation into a component's props.

export default graphql(logOnMutation)(Login);

That line of code above doesn't work. No errors showing, but doesn't provide mutate function into props of component.

But if I write like that:

const logOnWithMutation = graphql(logOnMutation)(Login);
export default logOnWithMutation;

and write like this

const App = () => {
  return (
    <ApolloProvider client={client}>
      <Fragment>
        <logOnWithMutation/>
      </Fragment>
    </ApolloProvider>
  )
}

it works perfectly.

So what am I missing? I need my first option to work


Solution

  • Decision:

    import your Login component in your's parent component as default like that import Login from './containers/login/login'; not through the exact name like import { Login } from './containers/login/login';