Skip to content

Conversation

@DaleSeo
Copy link
Contributor

@DaleSeo DaleSeo commented Aug 20, 2025

The MCP server is generating JSON schemas that don't match OpenAI's function calling specification. It puts oneOf at the array level instead of using items to define the JSON schemas for GraphQL list types. While some other LLMs are more flexible about this, it technically violates the JSON Schema specification that OpenAI strictly follows.

This PR updates the list type handling logic to move oneOf inside items for GraphQL list types.

Before

Valid input fails validation

2025-08-22 at 09 48 55

https://jsonschema.dev/s/kqwqR

After

Valid input passes validation

2025-08-22 at 09 50 05

https://jsonschema.dev/s/3jAXW

@DaleSeo DaleSeo self-assigned this Aug 20, 2025
@apollo-librarian
Copy link

apollo-librarian bot commented Aug 20, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 2 changed, 0 removed
* (developer-tools)/apollo-mcp-server/(latest)/limitations.mdx
* (developer-tools)/apollo-mcp-server/(latest)/guides/auth.mdx

Build ID: d56bdcb80a30068675edf9d2
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/d56bdcb80a30068675edf9d2

@apollographql apollographql deleted a comment from github-actions bot Aug 22, 2025
@DaleSeo DaleSeo requested a review from Jephuff August 22, 2025 14:12
@DaleSeo DaleSeo marked this pull request as ready for review August 22, 2025 14:12
@DaleSeo DaleSeo requested a review from a team as a code owner August 22, 2025 14:12
@swcollard
Copy link
Contributor

swcollard commented Aug 22, 2025

Is there a utility we can include in our unit tests that does the same validation as https://jsonschema.dev/ ?
That way we have more than just the snapshot to verify its correctness

@DaleSeo
Copy link
Contributor Author

DaleSeo commented Aug 22, 2025

Thanks for your input, @swcollard. With a customer waiting to evaluate the MCP server, merging this quick fix should be the immediate priority. I've created a backlog ticket for adding such unit tests, so we can address this improvement in a follow-up.

swcollard
swcollard previously approved these changes Aug 22, 2025
@DaleSeo DaleSeo requested a review from Jephuff August 22, 2025 17:53
fn empty_file() {
let result = CustomScalarMap::from_str("").err().unwrap();

insta::assert_debug_snapshot!(result, @r###"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unrelated to the PR change? I'd say if we want to change the style here we should make a separate PR? though maybe Im misremembering what these # do :D

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really mean to change this. 😅 I just accepted the snapshot changes that Insta generated. This might be cause by the recent dependency updates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these are just always updating, imo best to do a dedicated PR for updating the format, especially in unrelated files. For the ones in separate files it muddies the git history where this PR will show up in that files history, for the ones in the same file it makes reviewing more difficult.

I think you've got approval for the change so maybe not worth removing the ones in operations.rs, but I'd definitely encourage reverting the ones in this file to not muddy the history :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tracked down the relevant Insta changeset, but you're right. I agree it can be confusing to include unrelated changes in this PR. I'll revert the changes in this file.

Image

https://insta.rs/changelog/#1-40-0

],
"items": Object {
"oneOf": Array [
Object {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like all our array test currently only have scalars, could we have one that s a list of input objects? (one for nullable and one for non nullable)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added tests for input object lists.

@swcollard swcollard dismissed their stale review August 22, 2025 18:42

Dismiss

Copy link
Contributor

@swcollard swcollard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing 🚢

Comment on lines -1617 to +1636
"###);
"#);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking, but what caused the change in all these snapshots to use the single #?

Copy link
Contributor Author

@DaleSeo DaleSeo Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test code was written before Insta v1.40.0. It used to use ### for inline snapshots but now it uses # by default. See #272 (comment)

@DaleSeo DaleSeo merged commit ebc18f1 into main Aug 22, 2025
8 checks passed
@DaleSeo DaleSeo deleted the GT-349 branch August 25, 2025 19:30
@DaleSeo DaleSeo mentioned this pull request Aug 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants