-
Goal: Trying to use a custom input type for graphql resource.
-
Steps:
- Create a graphql resource whose input type is a custom object type (not a scalar type) in an app.
- Create a transformer (getRowsInput) to facilitate creating an input object
- Fill the input in the Variable section with the transformer (getRowsInput)
- Run the query - Get an error as below
[
{
"message":"Variable \"$input\" of non-null type \"GetASPartSalesListInput!\" must not be null.",
"locations":[
{
"line":1,
"column":23
}
],
"extensions":{
"code":"BAD_USER_INPUT",
"exception":{
"stacktrace":[
"GraphQLError: Variable \"$input\" of non-null type \"GetASPartSalesListInput!\" must not be null.",
" at coerceVariableValues (/home/node/node_modules/graphql/execution/values.js:122:9)",
" at getVariableValues (/home/node/node_modules/graphql/execution/values.js:45:21)",
" at /home/node/node_modules/@apollo/gateway/dist/index.js:512:67",
" at NoopContextManager.with (/home/node/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:36:24)",
" at ContextAPI.with (/home/node/node_modules/@opentelemetry/api/build/src/api/context.js:71:54)",
" at NoopTracer.startActiveSpan (/home/node/node_modules/@opentelemetry/api/build/src/trace/NoopTracer.js:67:28)",
" at ProxyTracer.startActiveSpan (/home/node/node_modules/@opentelemetry/api/build/src/trace/ProxyTracer.js:36:24)",
" at ApolloGateway.validateIncomingRequest (/home/node/node_modules/@apollo/gateway/dist/index.js:506:39)",
" at /home/node/node_modules/@apollo/gateway/dist/index.js:66:51",
" at NoopContextManager.with (/home/node/node_modules/@opentelemetry/api/build/src/context/NoopContextManager.js:36:24)"
]
}
}
}
]
- Details:
- The input is a custom type.
- Other queries in other applications work well but still they show the error
The value has to be of type 'string | number', you provided an object
as attached in the Screenshots section - When I try to fetch another graph (another type) in the query, it throws an error.
- ex)
query successfulQuery($input: SomeDataInput!) {
successfulQuery(input: $input) {
id
}
}
query failedQuery($input: SomeDataInput!) {
failedQuery(input: $input) {
id
relatedGraph { # <- this messes the whole query up
name
}
}
}
-
Without the related graph, it works fine despite the error message with a union type..
-
It had worked okay so far, it started not working today without any changes made to the query.
-
Screenshots:
-
Graphql resource in Retool
-
getRowsInput
(object) transformer
-
The error says
The value has to be of type 'string | number', you provided an object
.
-
Failed error after executing the query
-
server.xyz/graphql (Specs)
-
Successful result on
/graphql
-
My guess
The main reason may be the graphql queries do not recognize the object type input (non-scalar) and does not accept the provided object as an input and blanks it.