How to troubleshoot Unexpected Execution Error in GraphQL? - graphql

I am receiving an Unexpected Execution Error in my query result and was wondering how I would better understand the error. What does Unexpected Execution Error mean?
{
"errors":[
{
"message":"Unexpected Execution Error",
"locations":[
{
"line":2,
"column":3
}
],
"path":[
"createProfile"
]
}
],
"data":{
}
}

Related

Issue while Querying GraphQL API as a client

I am trying to run a query from postman like below and see HTTP 400 bad request as the error. Please help.
query getContract($data : String!){
contract(contractNumber: $data) {
contractNumber
versions(getCurrentContractVersion: true) {
nodes {
customer {
birthDate
legalEntityCode
}
contractAssets {
nodes {
assetDetails {
plate
}
}
}
}
}
}
}
Postman Response - HTTP 400 Bad request
{
"errors": [
{
"message": "Either the parameter query or the parameter id has to be set.",
"extensions": {
"code": "HC0013"
}
}
]
}

GraphQLError: Syntax Error: Expected Name, found Int \"-12\"

I've been trying to fix this bug and I haven't been able to figure it out. I know this is similar to some of the other threads I've seen on here but I've verified it's not a typo and that the issue isn't with an incorrect data type. Would really appreciate the help and for someone to point out what i'm missing here. Thanks!
Edit: Here's the stack trace
{
"errors": [
{
"message": "Syntax Error: Expected Name, found Int \"-12\".",
"locations": [
{
"line": 8,
"column": 27
}
],
"extensions": {
"code": "GRAPHQL_PARSE_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Syntax Error: Expected Name, found Int \"-12\".",
" at syntaxError (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/error/syntaxError.js:15:10)",
" at Parser.expectToken (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:1413:40)",
" at Parser.parseName (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:98:22)",
" at Parser.parseObjectField (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:591:21)",
" at Parser.item (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:575:21)",
" at Parser.any (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:1485:26)",
" at Parser.parseObject (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:580:20)",
" at Parser.parseValueLiteral (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:461:21)",
" at Parser.item (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:553:20)",
" at Parser.any (/Users/vn/Documents/Blockchain/fabric/blockchain-fabric-api/node_modules/graphql/language/parser.js:1485:26)"
]
}
}
}
]
}
You have creationTime as a string without quotes, so you need quotes
change it to this:
creationTime: "2007-12-03R10:15:30Z",

How can we catch unauthorized exception which been thrown by quarkus

I am facing this problem but don't know how to achieve it.
I have a graphql endpoint to fetch list of user, it already enabled authentication check.
Basically, when I send a request fetchUsers without authorization header it will throw exception or status code to let the user know, but currently, it just response
{
"errors": [
{
"message": null,
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"fetchUsers"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": {
"fetchUsers": null
}
}
And in the backend server, there have some exception throw:
SRGQL012000: Data Fetching Error: io.quarkus.security.UnauthorizedException
at io.quarkus.security.runtime.interceptor.check.AuthenticatedCheck.apply(AuthenticatedCheck.java:28)
at io.quarkus.security.runtime.interceptor.SecurityConstrainer.check(SecurityConstrainer.java:28)
at io.quarkus.security.runtime.interceptor.SecurityConstrainer_Subclass.check$$superforward1(SecurityConstrainer_Subclass.zig:100)
at io.quarkus.security.runtime.interceptor.SecurityConstrainer_Subclass$$function$$1.apply(SecurityConstrainer_Subclass$$function$$1.zig:41)
at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:54)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.proceed(InvocationInterceptor.java:62)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor.monitor(InvocationInterceptor.java:49)
at io.quarkus.arc.runtime.devconsole.InvocationInterceptor_Bean.intercept(InvocationInterceptor_Bean.zig:521)
Is there any way to catch this Unauthorized exception and custom it, to response 401 and the error message that we want to response.

How to fix "Syntax Error: Expected Name, found String \"query\"" in GraphQL

I'm trying to test the GraphQL server I built, by sending GraphQL queries to the server using Postman.
It works when I'm using raw radio button, but when I'm trying to use GraphQL radio button, it returns "message": "Syntax Error: Expected Name, found String \"query\"".
I have tried to change the syntax: mainly add or delete curly braces but nothing happened.
The query I sent in raw mode (working):
{
person(id:"123456789") {
personal_info {
address
}
}
}
The query I sent in GraphQL mode:
QUERY:
query getPerson ($id: String){
person(id: $id){
personal_info {
address
}
}
}
GRAPHQL VARIABLES:
{
"id": "123456789"
}
I expect to get the data I asked for, but I get the error message:
{
"errors": [
{
"message": "Syntax Error: Expected Name, found String \"query\"",
"locations": [
{
"line": 1,
"column": 2
}
]
}
]
}
I had the same problem. During researching I have found the next answer on stackoverflow, thanks #gbenga_ps.
Resolved by adding the correct header to Postman request:
Body of request should be something like next:
{
courses {
title
}
}
If incorrect content-type set, error like next happened:
{
"errors": [
{
"message": "Syntax Error: Expected Name, found String \"query\"",
"locations": [
{
"line": 1,
"column": 2
}
]
}
]
}

MailChimp API v3.0 Json Parse Error

When I try update store (Patch) I get an error in the response:
{
"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title":"JSON Parse Error",
"status":400,
"detail":"We encountered an unspecified JSON parsing error.","instance":""
}
My Json data is:
{
"Id":"1",
"ListId":"lalalala",
"Name":"Cat1",
"Domain":"",
"Platform":"",
"EmailAddress":"a#a.a",
"CurrencyCode":"USD",
"MoneyFormat":"",
"PrimaryLocale":"",
"Timezone":"",
"Phone":"",
"Address": {
"Address1":"",
"Address2":"",
"City":"",
"Province":"",
"ProvinceCode":"",
"PostalCode":"",
"Country":"",
"CountryCode":"",
"Longitude":0,
"Latitude":0
}
}
What is wrong with it?

Resources