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.

A limitation of Mutation?

See original GitHub issue

Hello,

When I do a mutation, I want to be able to return the type directly instead of wrapping it into another field:

So, I want to do:

mutation {
  createPerson {
    __typename // <-- this should give you 'PersonType', ideally
    id
    firstName
    lastName
  }
}

but it seems like in Graphene Django, you have to wrap it inside another field:

mutation {
  createPerson {
    __typename // <-- in reality, this does not give you 'PersonType'
    person {
      __typename // <-- this gives you 'PersonType'
      id
      firstName
      lastName
    }
  }
}

How can I achieve the former?

This is a common pattern. Even the official documentation has this pattern: http://graphql.org/learn/queries/#mutations

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
syrusakbarycommented, Sep 13, 2017

Hi @glusa8,

you can use the Output attr in the mutation:

class CreatePerson(graphene.Mutation):
    Output = Person
    ...
0reactions
a3ammarcommented, Dec 20, 2017

@honi I made it work by just returning the newly created instance:

def mutate(self, info, **kwargs):
    user = authenticate(info.context, **kwargs)
    if user and user != info.context.user:
        login(info.context, user)
    return user
Read more comments on GitHub >

github_iconTop Results From Across the Web

What are the limitations of the mutation breeding?
1 Answer · They are sometimes harmful to organism. · The frequencies of the mutants which are desirable are usually low. · The...
Read more >
What are the main limitations of the use of mutation ... - Toppr
The important limitations of mutation breeding are: They are sometimes harmful to organism. The frequencies of the mutants which are desirable are usually ......
Read more >
Effects of Mutation on Selection Limits in Finite Populations ...
When the selection pressure is weak (S <= 0.5), the limit is given approximately by 2Sσ(a)[1 - (1 + c(2))/k]/(θ + 1) for...
Read more >
Mutation Breeding: Pros, Cons and Achievements of ... - Plantlet
Limitations of Mutation Breeding · The frequency of desirable mutation will be very low. · The breeder has to screen a large population...
Read more >
List the limitation of mutation breeding. - Doubtnut
Watch complete video answer for “List the limitation of mutation breeding.” of Biology Class 12th. Get FREE solutions to all questions from ...
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