facebook / facebook/relay

mutation TypeError: Cannot read property 'modern' of undefined

Open
#2,168 5 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I´ve build the following mutation:

```
import {
commitMutation,
graphql
} from 'react-relay';

import { ConnectionHandler } from 'relay-runtime';

import environment from '../../../../environment';

const createMutation = graphql`
mutation CompanyMutation($company: CompanyInput!) {
createCompany(data: $company) {
id
}
}
`

export const createCompany = (company, callback) => {

const variables = {
company: company
}

console.log("Will call mutation");

commitMutation(
environment,
{
createMutation,
variables,
onCompleted: () => {
callback()
},
onError: (error) => {
throw new Error(error)
}
}
)
}

```
That is called from the following component:

```
class CompanyForm extends Component {

handleSave = data => {
createCompany(data, () => console.log('COMPANY CREATED'));
};

render = () => {
return (

);
};
}

export default CompanyForm;

```
I´m getting the following error:

![image](https://user-images.githubusercontent.com/10373990/32027484-0ac51dfc-b9c8-11e7-84ad-7d1bb30e1bb1.png)

Is this a bug ? What am I doing wrong in my mutation code ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.