question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Import multiple mutation as alias

See original GitHub issue

@bgentry

import { default as submitAnswers } from '../../gql/mutations/submitAnswers'; import { default as submit } from '../../gql/mutations/submit';

this.get('apollo').mutate({ submitAnswers, variables }, 'submitAnswers') throws an error -> TypeError: Cannot read property ‘kind’ of undefined at checkDocument

What is the proper way of using 2 mutations in the same controller?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
n1ru4lcommented, Jun 14, 2017
import submitAnswers from '../../gql/mutations/submitAnswers';
import submit from '../../gql/mutations/submit';

This works for me

0reactions
notmessengercommented, Jul 18, 2017

Running ember@2.14.1 and ember-apollo-client@0.3.2 I also ran into a problem when wanting an alias, such as:

import organizationsQuery from 'my-project/gql/queries/organizations'

I would receive the error of Error: query option is required. You must specify your GraphQL document in the query option.

Converting my call from

this.get('apollo').queryOnce({organizationsQuery})

to

this.get('apollo').queryOnce({query: organizationsQuery})

resolved the issue though, just as it did for @m0rgul

This makes sense though since when it was imported as query instead of organizationsQuery the ES6 syntax of .queryOnce({query}) was being interpreted as .queryOnce({query: query}) whereas .queryOnce({organizationsQuery}) is interpreted as .queryOnce({organizationsQuery: organizationsQuery}) which is an incorrect property to pass to queryOnce()

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL aliases for multiple actions - Skedulo Developer
Skedulo GraphQL supports mutations that include aliases for performing multiple actions. All mutations in a schema block are performed in a transaction, which ......
Read more >
composing multiple/reusable mutation components? #1867
We want to use the Mutation component, but conditionally execute on two Mutations (dependent on a prop received by the component it wraps)....
Read more >
Mutations in Apollo Kotlin - Apollo GraphQL Docs
Mutations are GraphQL operations that modify back-end data. As a convention in GraphQL, queries are read operations and mutations are write operations.
Read more >
Use Variables / Aliases / Fragments / Directives in Queries
Use variables, aliases, fragments and directives in Hasura queries. ... Aliases can be used to return objects with a different name than their...
Read more >
How to insert many mutations in a single GraphQL request?
Also like other queries, if you want to request the same field multiple times (run similarly-named mutations) you need to use an alias...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found