Skip to content

Unhandled GraphQL subscription error Error: GraphQL error: Cannot return null for non-nullable field Subscription.teamCreated #10

Description

@jakec-dev

I'm pulling my hair out with this issue...

I'm using this component:

<ListAllTeamsData
    data={data}
    subscribeToMoreTeams={() => {
        subscribeToMore({
            document: LIST_ALL_TEAMS_SUBSCRIPTION,
            updateQuery: (previousResult, { subscriptionData }) => {
                console.log(previousResult, subscriptionData)
                if (!subscriptionData.data) {
                    return previousResult
                }

                const { teamCreated } = subscriptionData.data

                return {
                    ...previousResult,
                    teams: [
                        ...previousResult.teams,
                        teamCreated.team
                    ],
                }
            },
        })
    }}
/>

And the scema:

export const LIST_ALL_TEAMS_SUBSCRIPTION = gql`
    subscription {
        teamCreated {
            team {
                name
                id
                status
                mobile
            }
        }
    }
`

It works fine when I run the subscription in the GraphQL playground, but I get the error in the app. I have no idea why. Any help? It won't even hit the console.log so there seems to be something wrong with 'document: LIST_ALL_TEAMS_SUBSCRIPTION', but from what I can tell it's all fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions