Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json-schema: use $ref from external definitions file #479

Closed
durdenx opened this issue May 27, 2020 · 4 comments
Closed

json-schema: use $ref from external definitions file #479

durdenx opened this issue May 27, 2020 · 4 comments
Labels
enhancement New feature or request source handler

Comments

@durdenx
Copy link

durdenx commented May 27, 2020

The json-schema specifictaion allows the use of an external definitions file: https://json-schema.org/understanding-json-schema/structuring.html#id1. This avoids repeating types in all files. Is it possible with graphql-mesh's json-schema handler ?

Example:

{ "$ref": "definitions.json#/address" }

Where definitions.json is a file in the same directory and contains an address type:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "address": {
    "type": "object",
    "properties": {
      "street_address": {
        "type": "string"
      },
      "city": {
        "type": "string"
      },
      "state": {
        "type": "string"
      }
    },
    "required": [
      "street_address",
      "city",
      "state"
    ]
  }
}
@ardatan ardatan added the bug Something isn't working label May 27, 2020
@ardatan
Copy link
Owner

ardatan commented May 27, 2020

It is not possible now, and PRs are welcome!

@ardatan ardatan added enhancement New feature or request source handler waiting for release and removed bug Something isn't working labels May 27, 2020
@ardatan
Copy link
Owner

ardatan commented Jun 1, 2020

Available in 0.2.1!

@ardatan ardatan closed this as completed Jun 1, 2020
@YuefengLi
Copy link

Is external ref available for yaml spec?
I am getting an error saying:

💥 🕸️  Mesh - Alerts  Failed to generate the schema Error: Invalid JSON pointer: ./common.yaml/components/schemas/PageInfo
    at Function.parse (C:\Repos\graphql-mesh-demo\node_modules\json-pointer\index.js:219:44)
    at Function.get (C:\Repos\graphql-mesh-demo\node_modules\json-pointer\index.js:49:60)

@ardatan
Copy link
Owner

ardatan commented Jun 23, 2022

Yes it works but you should use json pointer syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request source handler
Projects
None yet
Development

No branches or pull requests

3 participants