Closed as not planned
Closed as not planned
Description
Hi, I belief this is a bug.
I am connecting to a json rest API and I want to do this:
query MyQuery {
sleep {
sleep { # <-- Get rid of this level
start
end
score
}
}
}
Problem: Schema is correctly changed, but output is null now
So by follwing the example in the Documentation, my .meshrc.yaml
looks like this:
sources:
- name: SleepAPI
handler:
jsonSchema:
baseUrl: http://localhost:4100/
operations:
- type: Query
field: sleep
path: /sleep
method: GET
responseSchema: json-schemas/sleep_response.json
transforms: #
- replace-field: # Analog from the
replacements: # Documentation
- from: #
type: Query # <- Schema Query
field: sleep #
to: #
type: Sleep_History # <- Replace with
field: sleep # Array of Entries
scope: hoistValue #
REST API Return Sample
{
"sleep": [
{
"start": "2010-01-01T01:00:00+01:00",
"end": "2011-01-01T01:00:00+01:00",
"score": 123
},
{
"start": "2012-01-01T01:00:00+01:00",
"end": "2013-01-01T01:00:00+01:00",
"score": 456
},
{
"start": "2014-01-01T01:00:00+01:00",
"end": "2015-01-01T01:00:00+01:00",
"score": 789
}
]
}
JSON Schema
{
"type": "object",
"title": "Sleep History",
"properties": {
"sleep": {
"title": "History",
"type": "array",
"items": [
{
"type": "object",
"title": "Sleep Entry",
"properties": {
"start": {
"type": "string",
"format": "date-time"
},
"end": {
"type": "string",
"format": "date-time"
},
"score": {
"type": "number"
}
}
}
]
}
}
}
Result
Output in the Console (DEBUG=1)
🕸️ - SleepAPI - Query.sleep: => Returning { sleep: [[Object], [Object], [Object]] }
🕸️ - SleepAPI - Query.sleep: Response is not array but return type is list. Normalizing the response
🕸️ - Execute - MyQuery: Execution done with
{ data: { sleep: null } }
After transform, schema is as expected but the return is null
Reproduction
As Codesandbox:
https://codesandbox.io/s/reproduction-graphql-mesh-json-api-transform-e0t4b?file=/.meshrc.yaml
The Reproduction Repository:
https://github.com/D1no/reproduction-graphql-mesh-json-api-transform
npm install
npm start
Schema: Before Transform
schema {
query: Query
}
type Query {
sleep: Sleep_History
}
type Sleep_History {
sleep: [Sleep_Entry]
}
type Sleep_Entry {
start: DateTime
end: DateTime
score: Float
}
"A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."
scalar DateTime
Schema: After Transform
schema {
query: Query
}
type Query {
sleep: [Sleep_Entry]
}
type Sleep_Entry {
start: DateTime
end: DateTime
score: Float
}
"A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the `date-time` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar."
scalar DateTime
Originally posted by @D1no in #3526 (comment)
Metadata
Metadata
Assignees
Labels
No labels