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
Enum generation from a json schema does not work properly #424
Comments
@wsong-fv Thank you for opening this issue! |
@ardatan Nope, it still fails. Error message:
And this is the schema I tried to build:
I noticed that you guys didn't look into index.cjs.js in the json-schema module; since I managed to get the schema built after changing some lines within that file, I wonder if that is the root of the problem. Edit: the temp workaround I had seemed to still cause the new alpha version to fail. Edit 2: this version seems to break even non-enum schemas. Error msg:
Non-enum schema that I tried to build:
|
https://codesandbox.io/s/dreamy-cartwright-m6gkr?file=/package.json |
Hello, this is my package.json: "dependencies": {
"@graphql-mesh/cli": "0.1.18-alpha-fb45a87.0",
"@graphql-mesh/json-schema": "0.1.18-alpha-fb45a87.0",
"@graphql-mesh/openapi": "0.1.18-alpha-fb45a87.0",
"@graphql-mesh/runtime": "0.1.18-alpha-fb45a87.0",
"@graphql-mesh/transform-extend": "0.1.18-alpha-fb45a87.0",
"@graphql-mesh/transform-filter-schema": "0.1.18-alpha-fb45a87.0",
"@graphql-mesh/transform-prefix": "0.1.18-alpha-fb45a87.0",
"addresser": "^1.1.19",
"graphql": "^15.0.0",
"graphql-fields": "2.0.3",
"typescript": "^3.8.3"
},
"devDependencies": {
"ts-node": "^8.10.1"
} The schema I tried to build is up above, in the meshrc.yaml the relevant portion is: - name: NamaraAB
handler:
jsonSchema:
baseUrl: https://api.namara.io/v0/data_sets/b70e5999-1e16-4472-bd6a-a536d4f3d41e/data/en-2?geometry_format=wkt
operations:
- type: Query
field: NamaraABSearch
path: "&where=company_name%20LIKE%20%22%25{args.name}%25%22&select=company_name%2Ccompany_number%2Ccompany_type%2Cregistration_event%2Cregistration_date%2Caddress%2Cformatted_address%2Ccity%2Cprovince%2Cpostal_code%2Csource_url%2Cissue_date%2Cgeometry"
method: GET
responseSchema: api-schemas/namara_ab.json I am still getting the same error that I reported above. This fails when I try to run |
https://codesandbox.io/s/dreamy-cartwright-m6gkr?file=/package.json |
Hello @ardatan , after experimenting around, I have discovered that the combination of an openapi source and a json schema source causes the error. Running |
Available in v0.1.18! |
I was trying to generate
mesh.ts
with this json schema:and the compiler gave me an error that
CompanyType
does not exist.Full Error Message here:
After digging in the
node_modules
, I have found that in theindex.cjs.js
file, the methodvisitEnum
was causing the issue. ThecreateName
function originally had[propertyName, prefix].join('_')
which you can see below as the commented out line. It joined theCompanyType
enum with the prefixNameraAbSearch
, resulting in the nameCompanyTypeNameraAbSearch
, causing the program to fail to find the original name. This was fixed by removing the prefix from the argument.Note: that this can be overridden by changing the Enum name in the schema, as shown below.
However, the expected behaviour is that the parser should not require special schema modifications for it to function.
Original:
Fixed:
The text was updated successfully, but these errors were encountered: