Skip to content

Schema validation fails for JSON schema handlers #8652

@strangeAeon

Description

@strangeAeon

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate in the terminal.

Please make sure Mesh package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

When running yarn run mesh validate for a mesh containing a handler for a JSON schema the validation fails with the following error:

ERROR [source=Hello World]  Failed to generate the schema for the source
 Validation failed for "schemaWithAnnotations" under ".mesh/sources/Hello World": undefined 

To Reproduce

Steps to reproduce the behavior:

Expected behavior

The validation should be successful.

Additional context

After some additional digging I could trace down the actual error to be thrown by the validate function to be
[ "Directive 'transport' was removed from schema 'Query'" ].

It seems the structural representation of the transport directive differs between the two schemas compared during validation:

oldSchema:

  "extensions": {},
  "astNode": {
    "directives": [
      {
      	"kind": "Directive",
      	"name": { "kind": "Name", "value": "transport" },
      	"arguments": [
            {
              "kind": "Argument",
              "name": { "kind": "Name", "value": "subgraph" },
              "value": { "kind": "StringValue", "value": "Hello World" }
            },
            {
              "kind": "Argument",
              "name": { "kind": "Name", "value": "kind" },
              "value": { "kind": "StringValue", "value": "rest" }
            }
      	]
      }
    ]
  },
  // ...

newSchema:

  "extensions": {
    "directives": {
      "transport": { "subgraph": "Hello World", "kind": "rest" }
    }
  },
  // ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions