Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Subscriptions not working if using RenameRootFields #488

Closed
maxpain opened this issue Nov 13, 2018 · 2 comments
Closed

Subscriptions not working if using RenameRootFields #488

maxpain opened this issue Nov 13, 2018 · 2 comments
Labels
blocking Prevents production or dev due to perf, bug, build error, etc..

Comments

@maxpain
Copy link

maxpain commented Nov 13, 2018

Subscriptions not working if using RenameRootFields and schema stiching.
Example:

export default function makeHttpAndWsLink(uri, headers) {
	const httpLink = new HttpLink({ uri, fetch, headers })

	const wsLink = new WebSocketLink(
		new SubscriptionClient(uri, {
			reconnect: true,
			connectionParams: { headers }
		}, ws)
	)

	return split(isSubscription, wsLink, httpLink)
}

export default async function getSchema(): Promise<GraphQLSchema> {
	const link = makeHttpAndWsLink(HASURA_GRAPHQL_ENGINE_URL, { 'x-hasura-access-key': HASURA_ACCESS_KEY })
	const schema = await introspectSchema(link)
	const executableSchema = makeRemoteExecutableSchema({ schema, link })

	return transformSchema(executableSchema, [
		new RenameRootFields((operation, name, field) => 'hasura_' + name)
	])
}

GraphQL subscription:

subscription {
  hasura_games(limit: 1) {
    id
  }
}

An error:

{
  "errors": [
    {
      "message": "Cannot return null for non-nullable field subscription_root.hasura_games.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "hasura_games"
      ]
    }
  ]
}

ardatan/graphql-tools#997
hasura/graphql-engine#987

@ghost ghost added the blocking Prevents production or dev due to perf, bug, build error, etc.. label Nov 14, 2018
@nerdophile
Copy link

How did you solve it

@maxpain
Copy link
Author

maxpain commented Jul 8, 2019

@venkyyPoojari I just not use RenameRootFields :D

@glasser glasser closed this as completed Mar 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocking Prevents production or dev due to perf, bug, build error, etc..
Projects
None yet
Development

No branches or pull requests

3 participants