Magento – magento 2 graphQL not loading mutation in custom module graphql doc

graphqlmagento2.3

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)

schema.graphql

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{
    outputdata:outputdata!
}
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

Best Answer

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

mutation {
Createpracticedata(
 input:{
    name: "name"
    email: "email"
    description: "description"
 }
){
    id
    name
    email
    description
    publish_date
 }
}

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.

Related Topic