graphql-engine
graphql-engine copied to clipboard
Add ability to match uuid to String when creating remote schema relationship
Right now if I have a column with uuid
type and I want to pass its value as an argument to remote schema's String
field, I'm getting an error
Cannot validate remote relationship because expected type "String", but got "uuid"
But it's technically possible to match uuid
to String
, because any uuid can be converted to string. Moreover, String
is a superclass for any other GraphQL type, so value from any Postgre field could be matched to remote schema's String
like this.
on the same note matching postgres text
columns to graphql ID
should be possible as well :)
Any workaround suggested for uuid -> string mapping?
This is a major showstopper for us, is there any workaround? Or perhaps someone from the graphql-engine project can point us to where something like a mapper could be implemented so that the OpenSource community can put up a PR perhaps? I'll be more than glad to take a stab at it!
This is a major showstopper for us, is there any workaround?
@danazkari Personally, I've migrated Hasura's table from uuid
to String
, still using it as a primary key.
I made it work using a custom GraphQL type named 'uuid':
const typeDefs = gql`
scalar uuid
type Query {
user(id: uuid!): User
}
`;
const uuidScalarType = new GraphQLScalarType({
name: 'uuid',
description: 'Faux-UUID type to fool Hasura',
serialize(value) {
return value;
},
parseValue(value) {
return value;
},
parseLiteral(ast) {
return (ast as any).value;
}
});
const resolvers = {
uuid: uuidScalarType,
Query: {
user: (parent, args) => {
...
}
}
}
I made it work using a custom GraphQL type named 'uuid':
That's good if you can easily change your remote schema. Can't be done quickly in our case, for example https://github.com/puzl-ee/qube
I made it work using a custom GraphQL type named 'uuid':
That's good if you can easily change your remote schema. Can't be done quickly in our case, for example https://github.com/puzl-ee/qube
That's true. Just wanted to add that possibility for those that can and might stumble over this issue. I'd also prefer your suggested solution over my workaround.
Any updates on this @0x777 ?