# Issue with mutation

**URL:** <https://community.apollographql.com/t/issue-with-mutation/8942>\
**Category:** Connectors\
**Tags:** odyssey\
**Created:** [April 17, 2025, 10:31pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942 "2025-04-17T22:31:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![HNNWOSU](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/hnnwosu/32/6003_2.png) [@HNNWOSU](https://community.apollographql.com/u/HNNWOSU)\
**Post date:** [April 17, 2025, 10:31pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942/1 "2025-04-17T22:31:05Z")

</div>

I am constantly getting this error - ==\> Schema change detected for subgraph: listings  
error: Composition failed.  
error[E029]: Encountered 1 build error while trying to build a supergraph.

Caused by:  
INVALID\_BODY: [listings] `@connect(http: {body:})` on `Mutation.createListing` is not valid: nom::error::ErrorKind::Eof: : $args.input.title  
numOfBeds: $args.input.numOfBeds  
costPerNight: $args.input.costPerNight

I have changed the type Mutation to - type Mutation {  
“Create a new listing”  
createListing(input: CreateListingInput!): CreateListingResponse [@connect](https://github.com/connect)(  
source: “listings”,  
http: {  
POST: “/listings?listing[title]={$args.input.title}&listing[numOfBeds]={$args.input.numOfBeds}&listing[costPerNight]={$args.input.costPerNight}”,  
headers: [{ name: “Api-Key”, from: “api-key” }]  
}  
selection: “”"  
listing {  
id  
title  
numOfBeds  
costPerNight  
closedForBooking: closedForBookings  
description  
photoThumbnail  
latitude  
longitude  
amenities {  
id  
category  
name  
}  
}  
“”"  
)  
}

But I get back this - {  
“data”: null,  
“errors”: [  
{  
“message”: “Request failed”,  
“path”: [  
“createListing”  
],  
“extensions”: {  
“service”: “listings”,  
“http”: {  
“status”: 400  
},  
“connector”: {  
“coordinate”: “listings:Mutation.createListing@connect[0]”  
},  
“code”: “CONNECTOR\_FETCH”  
}  
}  
]  
}

I need your help

---

<div class="post-metadata">

**Author:** ![lennyburdette](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lennyburdette/32/84_2.png) [@lennyburdette](https://community.apollographql.com/u/lennyburdette)\
**Post date:** [April 17, 2025, 10:44pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942/2 "2025-04-17T22:44:38Z")

</div>

Hi, thanks for the question! If I’m reading correctly, you have two problems:

1. A parsing error on the `body` mapping. Unfortunately it’s hard to tell what the problem is from the error (something we need to improve!) — can you provide the code that causes this?
2. When trying to use query parameters, the endpoint is returning a 400 Bad Request. I don’t think this endpoint supports query parameters, so that makes sense. You can confirm this with [the debugging UI in Apollo Sandbox](https://www.apollographql.com/docs/graphos/schema-design/connectors/troubleshooting#return-debug-information-in-graphql-responses).

For #1, you could try this:

```auto
body: """
# this skips past the outer { $args: { input: ... } }
$args.input { 
  # to create an object with these properties:
  title
  numOfBeds
  costPerNight
}
"""
```

---

<div class="post-metadata">

**Author:** ![HNNWOSU](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/hnnwosu/32/6003_2.png) [@HNNWOSU](https://community.apollographql.com/u/HNNWOSU)\
**Post date:** [April 17, 2025, 11:50pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942/3 "2025-04-17T23:50:29Z")

</div>

Thanks so much for your response, I have added your code, but still getting bad response 400 error

---

<div class="post-metadata">

**Author:** ![HNNWOSU](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/hnnwosu/32/6003_2.png) [@HNNWOSU](https://community.apollographql.com/u/HNNWOSU)\
**Post date:** [April 17, 2025, 11:51pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942/4 "2025-04-17T23:51:45Z")

</div>

The complete code block - extend schema  
@link(url: “[https://specs.apollo.dev/federation/v2.10](https://specs.apollo.dev/federation/v2.10)”, import: [“@key”])  
@link(url: “[Apollo Connectors Directives - Apollo GraphQL Docs](https://specs.apollo.dev/connect/v0.1)”, import: [“@source”,“@connect”])  
@source(  
name: “listings”  
http: { baseURL: “[https://airlock-listings.demo-api.apollo.dev](https://airlock-listings.demo-api.apollo.dev)” }  
)

type Query {  
“A curated array of listings to feature on the homepage”  
featuredListings: [Listing!]! @connect(  
source: “listings”,  
http: { GET: “/featured-listings”}  
selection: “”"  
id  
title  
numOfBeds  
costPerNight  
closedForBooking: closedForBookings

```
"""

```

)  
“A listing by its ID”  
listing(id: ID!): Listing @connect(  
source: “listings”,  
http: { GET: “/listings/{$args.id}”}  
# The selection is the fields we want to return from the API  
selection: “”"  
id  
title  
numOfBeds  
costPerNight  
closedForBooking: closedForBookings  
description  
photoThumbnail: thumbnail  
latitude  
longitude  
“”"  
entity: true  
)  
}

“A particular intergalactic location available for booking”  
type Listing @key(fields: “id”) {  
id: ID!  
“The listing’s title”  
title: String!  
“The number of Beds Available”  
numOfBeds: Int  
“The cost per night”  
costPerNight: Float  
“Indicates whether listing is closed for booking (on hiatus)”  
closedForBooking: Boolean  
“The listing’s description”  
description: String  
“The listing’s thumbnail image URL”  
photoThumbnail: String  
“Latitude coordinates for the destination”  
latitude: Float  
“Longitude coordinates for the destination”  
longitude: Float  
“The Amenities available for this listing”  
amenities: [Amenity!]! @connect(  
source: “listings”,  
http: { GET: “/listings/{$this.id}/amenities”}  
# The selection is the fields we want to return from the API  
selection: “”"  
id  
category  
name  
“”"  
)

}

type Amenity {  
id: ID!  
“The amenity catgory the amenity belongs to”  
category: String!  
“The amenity name”  
name: String!  
}

input CreateListingInput {  
title: String!  
numOfBeds: Int!  
costPerNight: Float!

}

type CreateListingResponse {  
listing: Listing  
}

type Mutation {  
“Create a new listing”  
createListing(input: CreateListingInput!): CreateListingResponse @connect(  
source: “listings”,  
http: {  
POST: “/listings”,  
headers: [  
{ name: “Api-Key”, from: “Api-Key” }  
],  
body: “”"

# this skips past the outer { $args: { input: … } }

$args.input {

# to create an object with these properties:

title  
numOfBeds  
costPerNight  
}  
“”"  
}  
selection: “”"  
listing {  
id  
title  
numOfBeds  
costPerNight  
closedForBooking: closedForBookings  
description  
photoThumbnail  
latitude  
longitude  
amenities {  
id  
category  
name  
}  
}  
“”"  
)  
}

---

<div class="post-metadata">

**Author:** ![lennyburdette](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lennyburdette/32/84_2.png) [@lennyburdette](https://community.apollographql.com/u/lennyburdette)\
**Post date:** [April 18, 2025, 12:57pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942/5 "2025-04-18T12:57:10Z")

</div>

Hi! Could you put your code in a code block? It’s difficult to spot the problem. You can use three backticks above and below to wrap it in a block.

Did you try the debugger in Apollo Sandbox? [Troubleshooting Connectors - Apollo GraphQL Docs](https://www.apollographql.com/docs/graphos/schema-design/connectors/troubleshooting#return-debug-information-in-graphql-responses)

---

<div class="post-metadata">

**Author:** ![HNNWOSU](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/hnnwosu/32/6003_2.png) [@HNNWOSU](https://community.apollographql.com/u/HNNWOSU)\
**Post date:** [April 18, 2025, 1:16pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942/6 "2025-04-18T13:16:44Z")

</div>

The server starts and runs and I am able to execute all the query functions. The function I have troubles with is the Mutation. I kept getting the 400 error I specified earlier. The code block is

`extend schema  
@link(url: “[https://specs.apollo.dev/federation/v2.10](https://specs.apollo.dev/federation/v2.10)”, import: [“@key”])  
@link(url: “[Apollo Connectors Directives - Apollo GraphQL Docs](https://specs.apollo.dev/connect/v0.1)”, import: [“@source”,“@connect”])  
@source(  
name: “listings”  
http: { baseURL: “[https://airlock-listings.demo-api.apollo.dev](https://airlock-listings.demo-api.apollo.dev)” }  
)

type Query {  
“A curated array of listings to feature on the homepage”  
featuredListings: [Listing!]! @connect(  
source: “listings”,  
http: { GET: “/featured-listings”}  
selection: “”"  
id  
title  
numOfBeds  
costPerNight  
closedForBooking: closedForBookings

```
"""

```

)  
“A listing by its ID”  
listing(id: ID!): Listing @connect(  
source: “listings”,  
http: { GET: “/listings/{$args.id}”}  
# The selection is the fields we want to return from the API  
selection: “”"  
id  
title  
numOfBeds  
costPerNight  
closedForBooking: closedForBookings  
description  
photoThumbnail: thumbnail  
latitude  
longitude  
“”"  
entity: true  
)  
}

“A particular intergalactic location available for booking”  
type Listing @key(fields: “id”) {  
id: ID!  
“The listing’s title”  
title: String!  
“The number of Beds Available”  
numOfBeds: Int  
“The cost per night”  
costPerNight: Float  
“Indicates whether listing is closed for booking (on hiatus)”  
closedForBooking: Boolean  
“The listing’s description”  
description: String  
“The listing’s thumbnail image URL”  
photoThumbnail: String  
“Latitude coordinates for the destination”  
latitude: Float  
“Longitude coordinates for the destination”  
longitude: Float  
“The Amenities available for this listing”  
amenities: [Amenity!]! @connect(  
source: “listings”,  
http: { GET: “/listings/{$this.id}/amenities”}  
# The selection is the fields we want to return from the API  
selection: “”"  
id  
category  
name  
“”"  
)

}

type Amenity {  
id: ID!  
“The amenity catgory the amenity belongs to”  
category: String!  
“The amenity name”  
name: String!  
}

input CreateListingInput {  
title: String!  
numOfBeds: Int!  
costPerNight: Float!

}

type CreateListingResponse {  
listing: Listing  
}

type Mutation {  
“Create a new listing”  
createListing(input: CreateListingInput!): CreateListingResponse @connect(  
source: “listings”,  
http: {  
POST: “/listings”,  
headers: [  
{ name: “Api-Key”, from: “Api-Key” }  
],  
body: “”"

# this skips past the outer { $args: { input: … } }

$args.input {

# to create an object with these properties:

title  
numOfBeds  
costPerNight  
}  
“”"  
}  
selection: “”"  
listing {  
id  
title  
numOfBeds  
costPerNight  
closedForBooking: closedForBookings  
description  
photoThumbnail  
latitude  
longitude  
amenities {  
id  
category  
name  
}  
}  
“”"  
)  
}`

---

<div class="post-metadata">

**Author:** ![Michelle\_Mabuyo](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michelle_mabuyo/32/80_2.png) [@Michelle\_Mabuyo](https://community.apollographql.com/u/Michelle_Mabuyo)\
**Post date:** [April 22, 2025, 6:26pm UTC](https://community.apollographql.com/t/issue-with-mutation/8942/7 "2025-04-22T18:26:34Z")

</div>

We solved this yesterday [through comments in-lesson](https://github.com/apollographql-education/content-feedback/discussions/205#discussioncomment-12899830)!

The issue was the connector’s `selection` mapping. There needs to be a colon _after_ listing (`:`) to signify we’re defining a top-level `listing` property, with the value set to an object `{ }`, with all the properties we need.

---

<div class="post-metadata">

**Author:** ![martinanderson1](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/martinanderson1/32/6012_2.png) [@martinanderson1](https://community.apollographql.com/u/martinanderson1)\
**Post date:** [April 24, 2025, 11:45am UTC](https://community.apollographql.com/t/issue-with-mutation/8942/8 "2025-04-24T11:45:32Z")

</div>

This appears to be a 400 Bad Request error when attempting to send a POST request using the `@connect` directive. This may be due to a number of reasons, like improper formatting of the body of the request or omitted parameters. In your `@connect` directive, the URL building with query parameters (`listing[title]={$args.input.title}`) could be not interpolating the variables correctly, or the body could be not formatted as expected by the endpoint. I would recommend you to check a few things: ensure the API endpoint is accepting query parameters in the URL and not in the body, confirm that all mandatory fields are being sent correctly, and double-check the headers, especially the `Api-Key` format. You could also log the actual request that is being sent to identify where the failure is occurring. If possible, test the request in isolation (e.g., via Postman) to ensure the API is behaving as expected outside of the GraphQL layer.
