Comments (13)
Thanks @pelletier197 for the fast reply. I've added it on config and it throws the same error, here's the full log:
Command 'pnpm' failed with status 1 when executed in directory /var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]
---- Program Output----
> @magidoc/[email protected] build /private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]
> svelte-kit build
vite v2.9.10 building for production...
transforming...
✓ 580 modules transformed.
rendering chunks...
.svelte-kit/output/client/_app/immutable/manifest.json 4.86 KiB
.svelte-kit/output/client/_app/immutable/pages/__error.svelte-5f5d1a2d.js 1.16 KiB / gzip: 0.69 KiB
.svelte-kit/output/client/_app/immutable/pages/_...page_.svelte-11d34174.js 1.05 KiB / gzip: 0.59 KiB
.svelte-kit/output/client/_app/immutable/pages/index.svelte-90b5b8fc.js 0.22 KiB / gzip: 0.19 KiB
.svelte-kit/output/client/_app/immutable/pages/mutations/_mutation_.svelte-ba79272f.js 1.56 KiB / gzip: 0.84 KiB
.svelte-kit/output/client/_app/immutable/pages/queries/_query_.svelte-7f7810e7.js 1.53 KiB / gzip: 0.83 KiB
.svelte-kit/output/client/_app/immutable/pages/subscriptions/_subscription_.svelte-d112382f.js 1.58 KiB / gzip: 0.85 KiB
.svelte-kit/output/client/_app/immutable/start-69b04ef6.js 25.59 KiB / gzip: 9.18 KiB
.svelte-kit/output/client/_app/immutable/pages/__layout.svelte-be4fa9bb.js 35.20 KiB / gzip: 10.52 KiB
.svelte-kit/output/client/_app/immutable/chunks/paths-8dcd8f6b.js 0.86 KiB / gzip: 0.53 KiB
.svelte-kit/output/client/_app/immutable/chunks/ChevronDown-6302633b.js 1.66 KiB / gzip: 0.92 KiB
.svelte-kit/output/client/_app/immutable/chunks/index-32191452.js 9.88 KiB / gzip: 3.88 KiB
.svelte-kit/output/client/_app/immutable/assets/pages/types/_type_.svelte-ea72c5bf.css 0.23 KiB / gzip: 0.18 KiB
.svelte-kit/output/client/_app/immutable/pages/types/_type_.svelte-de89b16d.js 31.91 KiB / gzip: 6.45 KiB
.svelte-kit/output/client/_app/immutable/assets/pages/__error.svelte-45f46132.css 0.13 KiB / gzip: 0.13 KiB
.svelte-kit/output/client/_app/immutable/assets/FieldDetails-077d5dc0.css 0.18 KiB / gzip: 0.14 KiB
.svelte-kit/output/client/_app/immutable/assets/PreviousNextPage-00e2b760.css 1.25 KiB / gzip: 0.41 KiB
.svelte-kit/output/client/_app/immutable/assets/pages-69fbf403.css 5.44 KiB / gzip: 1.58 KiB
.svelte-kit/output/client/_app/immutable/chunks/ArgsList-01b31947.js 23.40 KiB / gzip: 6.94 KiB
.svelte-kit/output/client/_app/immutable/chunks/PreviousNextPage-34f1767a.js 47.33 KiB / gzip: 15.97 KiB
.svelte-kit/output/client/_app/immutable/assets/pages/__layout.svelte-4dec8d5f.css 737.09 KiB / gzip: 64.61 KiB
.svelte-kit/output/client/_app/immutable/chunks/FieldDetails-f0adf12a.js 507.26 KiB / gzip: 151.48 KiB
.svelte-kit/output/client/_app/immutable/chunks/pages-e8f606df.js 2394.64 KiB / gzip: 186.44 KiB
(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
vite v2.9.10 building SSR bundle for production...
transforming...
"GraphQLObjectType" is imported from external module "graphql" but never used in "src/lib/components/tags/TypeTag.svelte", "src/lib/components/tags/NullableTag.svelte", "src/lib/components/type/TypeLink.svelte", "src/lib/model.ts" and "src/routes/types/[type].svelte".
✓ 429 modules transformed.
Generated an empty chunk: "hooks"
rendering chunks...
.svelte-kit/output/server/manifest.json 4.43 KiB
.svelte-kit/output/server/index.js 74.30 KiB
.svelte-kit/output/server/entries/pages/__error.svelte.js 1.27 KiB
.svelte-kit/output/server/entries/pages/_...page_.svelte.js 1.09 KiB
.svelte-kit/output/server/entries/pages/index.svelte.js 0.28 KiB
.svelte-kit/output/server/entries/pages/mutations/_mutation_.svelte.js 1.73 KiB
.svelte-kit/output/server/entries/pages/queries/_query_.svelte.js 1.70 KiB
.svelte-kit/output/server/entries/pages/subscriptions/_subscription_.svelte.js 1.76 KiB
.svelte-kit/output/server/entries/pages/types/_type_.svelte.js 15.43 KiB
.svelte-kit/output/server/chunks/paths-396f020f.js 0.16 KiB
.svelte-kit/output/server/chunks/index-ef261cd9.js 9.26 KiB
.svelte-kit/output/server/chunks/ChevronDown-fc666eff.js 1.36 KiB
.svelte-kit/output/server/chunks/PreviousNextPage-48fcfb1e.js 61.21 KiB
.svelte-kit/output/server/chunks/FieldDetails-797404db.js 23.76 KiB
.svelte-kit/output/server/chunks/TypeLinkTag-1aad5233.js 12.54 KiB
.svelte-kit/output/server/chunks/hooks-1c45ba0b.js 0.00 KiB
.svelte-kit/output/server/entries/pages/__layout.svelte.js 777.85 KiB
.svelte-kit/output/server/chunks/pages-ea90250b.js 4442.73 KiB
302 / -> /introduction/welcome
Error: Cannot generate a random value for scalar 'smallint'.
The random generator is not able to randomly generate a value for non-standard GraphQL scalars.
You have to provide a custom factory by providing this in your config:
{
'smallint': () => generateRandomCustomScalar()
}
at randomFactory (file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected]/node_modules/@magidoc/plugin-query-generator/build/generator/fakeGenerator.js:101:19)
at findMostSpecificFactory (file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected]/node_modules/@magidoc/plugin-query-generator/build/generator/fakeGenerator.js:92:12)
at generateInput (file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected]/node_modules/@magidoc/plugin-query-generator/build/generator/fakeGenerator.js:49:21)
at file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected]/node_modules/@magidoc/plugin-query-generator/build/generator/fakeGenerator.js:116:24
at /private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:13469:38
at /private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:4967:15
at baseForOwn (/private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:3032:24)
at Function.mapValues (/private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/[email protected]/node_modules/lodash/lodash.js:13468:7)
at file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected]/node_modules/@magidoc/plugin-query-generator/build/generator/fakeGenerator.js:115:22
at generateInput (file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected]/node_modules/@magidoc/plugin-query-generator/build/generator/fakeGenerator.js:49:68)
> 500 /queries/account (linked from /introduction/welcome)
at file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sveltejs/kit/dist/chunks/index.js:1022:11
at save (file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sveltejs/kit/dist/chunks/index.js:1241:4)
at visit (file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected][email protected]/node_modules/@sveltejs/kit/dist/chunks/index.js:1132:3)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
ELIFECYCLE Command failed with exit code 1.
this is the config:
export default {
introspection: {
type: "url",
url: "http://localhost:9091/v1/graphql",
headers: {
"x-hasura-admin-secret": "myadminsecretkey",
},
},
website: {
template: "carbon-multi-page",
queryGenerationFactories: {
smallint: 42
}
},
};
from magidoc.
That makes sense!
It would be great to do a check first, will save some time while building the config since we won't have to cross check our scalars against it.
Another option is to have them predefined, at least the most common ones like eg timestamp
, date
, uuid
and let the user override them on options.queryGenerationFactories
if desired.
from magidoc.
great, these are some common Hasura scalars:
{
_text: "loremipsum",
bigint: 1000,
date: "2022-03-06T08:23:45.000Z",
float8: 0.1,
geography: { type: "Point", coordinates: [0, 0] },
geometry: { type: "Point", coordinates: [0, 0] },
jsonb: {},
numeric: 1,
smallint: 42,
timestamp: "2022-03-06T08:23:45.000Z",
timestamptz: "2022-03-06T08:23:45.000Z",
uuid: "a12ce80c-42e3-4149-89cc-4afda30e5e7f",
}
After adding all these scalars above it throws a new error:
Error: Fatal error: A recursive input with a non-nullable circular reference was detected, which makes it impossible to generate a query. If you ever see this error, it means that your GraphQL uses an invalid schema.
at generateInput (file:///private/var/folders/yz/dk5dbx8n2hqcfk1kdktxmknh0000gn/T/[email protected]/node_modules/.pnpm/@[email protected]/node_modules/@magidoc/plugin-query-generator/build/generator/fakeGenerator.js:34:23)
ps. I'm using Hasura 2.7.0
I'll try to debug it
from magidoc.
You're welcome @pelletier197, and again, thanks for this great generator. If you need anything please tag me! If you want to get exactly the same experience like mine then visit Hasura Getting Started.
from magidoc.
Thank you for raising this issue. So this is an error thrown by the Query generator plugin, which is not entirely accurate when using the magidoc template directly. I will improve the error message for this special error, since I expect it may happen quite often.
To solve it, you need to provide a query generation factory
in the magidoc config
export default {
introspection: {
// ...
},
website: {
// ...
queryGenerationFactories: {
smallint: 42
}
}
}
More detail about it can be found here.
from magidoc.
Oh.. sorry, my bad. I wrote this on my phone, should have opened my computer 😅. Simply wrap it in an options
key:
export default {
introspection: {
type: "url",
url: "http://localhost:9091/v1/graphql",
headers: {
"x-hasura-admin-secret": "myadminsecretkey",
},
},
website: {
template: "carbon-multi-page",
options: {
queryGenerationFactories: {
smallint: 42
}
}
},
};
from magidoc.
yeah, you are right, on the docs link you provided above it's inside an options
object but was hard to spot due to the many comments 😅.
Probably this is not possible: Can we first check for unknown scalars prior reaching the Build Template step? It takes lot's of time to build and throw an error if scalar is not known. We know witch scalars are not compatible before hand of course, just saying.
Thanks @pelletier197, keep it up!
from magidoc.
I can try to look if I could find a way to do that, or at least show all the missing scalars at once in the error.
You're right, it's not necessarily easy, because the cli doesn't actually do anything with the options
, it simply forwards them directly to the template. And since the factories support glob syntax as well, it adds a little bit of complexity.
I'll see what I can do, thanks for the idea!
from magidoc.
There are some default factories, but very few. I'll add those you mentioned, they clearly seem like common things that could come back in many APIs.
If you have other common scalars that could be there by default, let me know, I'll add them as well 🙂
from magidoc.
Thanks. Those all seem reasonable to add to the default factories.
About your error, thanks for taking the time to check it.
I'll check it out as well when I get some time. Would it be possible for you to provide me with the _schema.json
file for your API? If not possible, a minimal reproduction schema would be great otherwise.
I feel like this error message needs more detail as well.
from magidoc.
Sorry but I cannot share anything, it's a private repo. :(
It fails on the account_insert_input
, this is how I found it:
if (!isNullableType(input)) {
console.log(
"type: ",
unwrappedType,
"input: ",
input,
"name: ",
unwrappedType.name
);
throw new Error(
"Fatal error: A recursive input with a non-nullable circular reference was detected, which makes it impossible to generate a query. If you ever see this error, it means that your GraphQL uses an invalid schema."
);
}
this spits out type: "account_insert_input" input: "account_insert_input!" name: account_insert_input
, this input type has 0 non-null types and this table has some (ORM) table connections: eg:
input account_insert_input {
about_me: String,
show_seen_sent: Boolean
targeted_matches: match_arr_rel_insert_input
time_format: String
unban_reason: String
unbanned_at: timestamptz
unbanned_by: account_obj_rel_insert_input
unbanned_by_id: String
updated_at: timestamptz
verified_by: account_obj_rel_insert_input
verified_by_id: String
devices: device_arr_rel_insert_input
}
where device_arr_rel_insert_input
type is:
"input type for inserting array relation for remote table \"device\""
input device_arr_rel_insert_input {
data: [device_insert_input!]!
"upsert condition"
on_conflict: device_on_conflict
}
account_obj_rel_insert_input
type is:
"input type for inserting object relation for remote table \"account\""
input account_obj_rel_insert_input {
data: account_insert_input!
"upsert condition"
on_conflict: account_on_conflict
}
wish I could provide more info, best thing you can do is to run a Hasura docker instance and create a simple database. Hasura has weird schema in general.
from magidoc.
Okay, I think I get the issue. I'll open another bug for that. This is recursion with two layers, I'm gonna see how I can fix this, not an easy one.
In the meantime, you could probably do something like this if you're blocked and it's the only thing like this in your API.
{
queryGenerationFactories: {
device_arr_rel_insert_input: null,
'device_arr_rel_insert_input!': {} // an example
}
}
Thanks for all the help by the way, really appreciated!
from magidoc.
The issue with the recursion should be fixed now in 2.1.0, along with a few other improvements. Let me know if you have other issues.
I have not implemented the default types of Hasura yet, cause I have a little bit of confusion looking at the types example you shared compared to Hasura's docs. I'll need a little more research before implementing them. See #93 for more details.
from magidoc.
Related Issues (20)
- Query generator for unknown values HOT 4
- Support download links HOT 4
- Blacklisting HOT 2
- Alternative documentation layout HOT 4
- Large scale GraphQL APIs HOT 3
- preview command with --host option HOT 3
- Hosting on AWS S3 Bucket fails to find subfolders HOT 3
- magidoc generate started failing generating what looks like valid types HOT 11
- Fuse Markdown doesn't support enhanced markdown syntax HOT 3
- SyntaxError: Invalid or unexpected token HOT 1
- Fetch @magidoc/starter-carbon-multi-page From NPM Registry HOT 2
- bug: unordered lists render incorrectly HOT 7
- this portion of the fake generator should be unreachable... if you ever see this error, please open an issue HOT 2
- How do i deploy these docs in FastAPI HOT 2
- `@oneOf` directive support HOT 15
- Raw SDL is not working HOT 2
- 4.2.0 breaks siteRoot configuration variable HOT 2
- Command line parameter to specify .mjs file HOT 1
- Relative URLs not supported in markdown HOT 5
- For compatibility with markdown generated by other MD editors, allow optional space between container tag and type HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magidoc.