I created a custom module for mutation

with table

when I create mutation is not loading in graphql doc

Type \"PracticeOutput\" not found in document.\n\nException #0 (GraphQL\\Error\\Error)


type Query {
    Practice: outputdata @resolver(class: "GraphQL\\Practice\\Model\\Resolver\\Output") @doc(description: "The pratice query returns information ")
    Practicid(id:Int! @doc(description: "Get data based on id")):
    outputdata @resolver(class: "GraphQL\\Practice\\Model\\Resolver\\Idoutput") @doc(description: "The pratice query returns information ")
type Mutation {
    Createpracticedata (input:practiceinput!): PracticeOutput @resolver(class: "GraphQL\\Practice\\Model\\Resolver\\Create") @doc(description: "The pratice query Create ")

type outputdata @doc(description: "Return all data  in the table") {
    id: Int
    name: String
    email: String
    description : String
    publish_date: String

type PracticeOutput{
input practiceinput{
    name:String @doc(description: "The customer's first name")
    email: String @doc(description: "The customer's email address")
    description:String @doc(description:"The description about data")

but query is loading in graphql doc

Only parameter query is accepting not accepting Input - type

  • What is your mutation query you have submit? – Mujahidh Dec 23 '19 at 7:13

According to your Shema.graphqls your mutation should look like below.

mutation {
    name: "name"
    email: "email"
    description: "description"

As per your error in the post, you don't need to include PracticeOutput in your Mutation.Just pass the return attributes defined in the output. I wrote an article about How to write grapgQl mutation to create and integrate the contact us page functionality in magento 2.3.2?.

I used graphql Mutation to implement contact us page.Please check that. Hope this answer will help you.

| improve this answer | |
  • As per your answer above mutation is displaying a success message that's ok, but how can we display data instead of success message have passed in the input parameter? – Chirag Patel Jan 17 at 7:23
  • @ChiragPatel are you referring to contactus custom Mutation? If yes you can return the you can return the input data from your resolver. If you want them to show one by one, then you want to edit your ContactusOutput and define the out ut variables there and pass the values for out put data in the resolver. wHEN YOU CALL THE MUTATION PASSED THE NEWLY ADDED OUTPUTDATA VARIABLE IN GRAPHQL QUERY, – Mujahidh Jan 20 at 12:20
  • 1
    Thanks for your valuable time! I will check ContactusOutput and let you know if I facing any other issues. – Chirag Patel Jan 21 at 4:38
  • 1
    @ChiragPatel yes please.Always there to help as i can :) – Mujahidh Jan 21 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.