-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
getOptimisticResponse for custom scalars not working as expected #368
Comments
It looks like that objects can't be passed through a field in |
@juhaelee What is the fat query for this mutation? |
getFatQuery(){
return Relay.QL`
fragment on CreatePointPayload {
gridEdge,
}
`;
} Here is also my custom scalar for reference: (I'm using Joi for validation) import { GraphQLScalarType } from "graphql";
import { Kind } from "graphql/language";
import Joi from "joi";
const coerceCoordinate = (val) => {
var schema = {
x: Joi.number(),
y: Joi.number()
};
const {error, value} = Joi.validate(val, schema);
if(error){ return null; }
return value;
};
export default new GraphQLScalarType({
name: "Coordinate",
serialize: coerceCoordinate,
parseValue: coerceCoordinate,
parseLiteral(ast){
return ast.kind === Kind.OBJECT ? ast.value : null;
}
}); |
Custom scalar types are a new feature in OSS GraphQL, but it would seem that the value for such a field would have to actually be a scalar, ie, it should serialize to a string, number, or boolean. I think that |
Just to clarify, |
I'm double-checking my assumption with @dschafer - but yeah, I was thinking in |
I looked into this and the problem is in Using cc @yuzhi @yungsters |
Cool, thanks for all your help! |
|
I have a custom scalar that is called
coordinate
that takes a shape like this {x: INT, y: INT}When I try to do use
getOptimisticResponse
on an"RANGE_ADD"
I have something like this:but when my container receives this update, coordinate exists, but appears as an empty object without the coordinate attributes. ( coordinate: {dataID: "client:SOMENUMBER"} ).
this.props.point
has the correct value before it is returned ingetOptimisticResponse
as well.I've also tried something like this, to no success:
Wondering if Relay can't support custom scalars in optimistic updating yet?
The text was updated successfully, but these errors were encountered: