Thanks for the tip regarding the ID. I will look into that.
As for your schema stiching problem, if you are using the Graphql Codegen, you could try to extend the remote object using something like this:
extend type Product {
quantity: Int!
isValid: Boolean!
}
But I have only used this to add extra fields to an existing type, not to override existing ones. On that subject, is it absolutely necessary to override the remote field? Can't you create a local boolean field that uses the remote one as a reference?
As for the readFragment and writeFragment question: yes, you use them with sibling fields and with any other type that has an ID and a __typename. For example:
So you can read and write to sibling fields using readFragment and writeFragment, but since you have to pass the ID of the object you want, you can only read and write to one at the time.
If you want to change two or more siblings at the same time, I would recommend using either using a query or a fragment that retrieves a higher level element, for example:
const productQuery = gql`
query ProductQuery {
productsEdge {
edges {
node {
numericalId
name
}
}
}
}
`;
const productsFragment = gql`
fragment products on ProductEdge {
edges {
node {
numericalId
name
}
}
}
`;
Hi @1awaleed ,
Thanks for the tip regarding the ID. I will look into that.
As for your schema stiching problem, if you are using the Graphql Codegen, you could try to extend the remote object using something like this:
But I have only used this to add extra fields to an existing type, not to override existing ones. On that subject, is it absolutely necessary to override the remote field? Can't you create a local boolean field that uses the remote one as a reference?
As for the
readFragment
andwriteFragment
question: yes, you use them with sibling fields and with any other type that has anID
and a__typename
. For example:You can read and write the products above like this:
So you can read and write to sibling fields using
readFragment
andwriteFragment
, but since you have to pass theID
of the object you want, you can only read and write to one at the time.If you want to change two or more siblings at the same time, I would recommend using either using a query or a fragment that retrieves a higher level element, for example:
I hope this answers you question.
Thanks,
Felipe
Thanks a lot @ Felipe, you have been helped a lot.