0

I have tried to extend the schema mutation

by adding schema.graphql in my module &

type Mutation {
    revokeCustomerToken(pagedata: PageData): RevokeCustomerTokenOutput @resolver(class: "\\Vendor\\CustomerGraphQl\\Model\\Resolver\\RevokeCustomerToken") @doc(description:"Revoke the customer token")
}


input PageData {
    location: String @doc(description: "The location from where the login performed")
    login_type: String @doc(description: "The login type, such as manual or facebook")
    page_path: String @doc(description: "The path of the page")
    page_referrer: String @doc(description: "The page referrer")
    page_title: String @doc(description: "Title of the page")
    page_url: String @doc(description: "The page url")
}

but i am getting Syntax Error GraphQL request (4:15) Expected Name error

i try with this schema in chrome tool

mutation {
  revokeCustomerToken {
    result
    pagedata: {
  location: "test"
  login_type: "test"
  page_path: "[email protected]"
  page_referrer: "test"
  page_title: "test"
  page_url: "test"
}
  }
}

any thoughts on this ?

3
  • any thoughts on this ?
    – devhs
    Mar 17, 2021 at 7:35
  • Is it even possible to pass data ? in thi
    – devhs
    Mar 18, 2021 at 7:03
  • any thoughts on this ?
    – devhs
    Mar 18, 2021 at 7:26

1 Answer 1

0

This is very common error and can be found mostly when there are unclosed curly braces or when some fields are not properly defined while calling the query. However, by looking at your code I found 2 suggestions which can help you to resolve this error.

First solution :

You are referencing a type that is defined further down. Move the type you are referencing up. You can check by swapping the code as below:

input PageData {
    location: String @doc(description: "The location from where the login performed")
    login_type: String @doc(description: "The login type, such as manual or facebook")
    page_path: String @doc(description: "The path of the page")
    page_referrer: String @doc(description: "The page referrer")
    page_title: String @doc(description: "Title of the page")
    page_url: String @doc(description: "The page url")
}

type Mutation {
    revokeCustomerToken(pagedata: PageData): RevokeCustomerTokenOutput @resolver(class: "\\Vendor\\CustomerGraphQl\\Model\\Resolver\\RevokeCustomerToken") @doc(description:"Revoke the customer token")
}

Second Solution :

Kindly change the pagedata key written in the type mutation curly bracket. From (pagedata: PageData) to (input: PageData).

I hope one of the above solutions work for you. If not please let me know, I will think more in detail regarding this.

Thanks,

7
  • Thanks for the answer pratik, what will be the mutation then to test it ? something like mutation { revokeCustomerToken { result pagedata { page_path : 'login' } } }
    – devhs
    Mar 18, 2021 at 6:19
  • @devhs, yes you may check like that and lets see what it gives in return. Mar 18, 2021 at 6:21
  • It gives me syntax errors i have updated question & added what i try to check
    – devhs
    Mar 18, 2021 at 6:23
  • I check with this tool - chrome.google.com/webstore/detail/graphql-playground-for-ch/…
    – devhs
    Mar 18, 2021 at 6:24
  • Any thoughts @pratik ?
    – devhs
    Mar 18, 2021 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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