Open tomasherout opened 2 years ago
Scalars like uuid
are in-built custom scalars in Hasura. These need not be redefined in actions when you have a table with uuid
type already. Hence, you do not get them explicitly when you export them.
Yes, but schema file metadata/actions.graphql
is invalid without defined scalars. I don't think define them manually in Hasura Console.
In case file metadata/actions.graphql
includes all non-built in GraphQL scalars (other than Int, Float, String, Boolean and ID) than it can be used for other purposes (like code generation). Currently the file is invalid for this purpose:
% graphql-codegen --config graphql/hasura-actions/codegen.yml
(node:3212) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
✔ Parse configuration
❯ Generate outputs
❯ Generate graphql/hasura-actions/generated.ts
✖ Load GraphQL schemas
→ Failed to load schema
Load GraphQL documents
Generate
Found 1 error
✖ graphql/hasura-actions/generated.ts
Failed to load schema from hasura/metadata/actions.graphql:
Unknown type: "uuid".
Error: Unknown type: "uuid".
This also applies to the new experimental support for Apollo Federation where the gateway can ask hasura for its schema sdl e.g. query { _service { sdl } }
but the schema returned from this endpoint is invalid because it does not contain the scalar types used in the schema
/usr/app/node_modules/@apollo/gateway/src/supergraphManagers/IntrospectAndCompose/index.ts:118
throw Error(
^
Error: A valid schema couldn't be composed. The following composition errors were found:
[hasura] Unknown type uuid
@kdawgwilk Thanks for raising this. Do you mind raising a new ticket for this issue with Apollo Federation integration specifically? The original ask on Actions, although quite similar in essence, is in a very different module.
Yes I opened an issue here #9115
BTW: This issue is now biting me when upgrading my schema from 2.8.0 to 2.33.2.
The postgres uuid scalar is no longer auto applied, meaning my schema is in an inconsistent state.
The actual solution:
Change all references to uuid
to Uuid
in actions.graphql
and actions.yaml
.
The fix is to do the following:
To actions.graphql
add anywhere (I added to the top):
scalar uuid
To actions.yaml
replace in the custom_types
key:
custom_types:
...
scalars: []
Change to:
scalars:
- name: uuid
I imagine the same would be true for the postgres geography
scalar.
Version Information
Server Version: 2.6.0 CLI Version (for CLI related issue): 2.6.0
Environment
OSS
What is the expected behaviour?
File
metadata/actions.graphql
should contains scalars definitions.Without them file can't be used for code generation with tools like GraphQL Code Generator
Keywords
actions.graphql scalars
What is the current behaviour?
Scalars used in actions are not defined in file
metadata/actions.graphql
How to reproduce the issue?
Run
hasura export
command in hasura-cli.Screenshots or Screencast
Any possible solutions?
Include scalars definitions for types used in actions like:
Can you identify the location in the source code where the problem exists?
No
If the bug is confirmed, would you be willing to submit a PR?
I am not familiar with Haskell