facebook / facebook/relay

React-relay GraphQL Subscription Error (Expected null to be a GraphQL composite type)

Open
#2,164 2 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 got error when I add GraphQL for subscription of CreateMutation.

### Code (FileName: `CreateHourSubscription.js` )

```sh
import {
graphql,
requestSubscription
} from 'react-relay'
import environment from '../Environment'

const subscription = graphql`
subscription CreateHourSubscription{
Hour{
mutation
node{
id
amount
}
}
}
`
// 3
export default () => {
const subscriptionConfig = {
subscription: subscription,
variables: {},
updater: proxyStore => {
const createHourField = proxyStore.getRootField('Hour')
const newHour = createHourField.getLinkedRecord('node')
const hourId = newHour.getValue('id')
const newHourDesc = newHour.getValue('description')
const newHourAmount = newHour.getValue('amount')


const hour = proxyStore.get(hourId)
hour.setValue(newHourAmount, 'amount')
hour.setValue(newHourDesc, 'description')
},
onError: error => console.log(`An error occured:`, error)
}

requestSubscription(
environment,
subscriptionConfig
)
}
```

### This is error message;
```sh
HINT: pass --watch to keep watching for changes.
Parsed default in 0.01s

Writing default
ERROR:
Expected null to be a GraphQL composite type.
```

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.