Skip to content
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

Updating a document resets reference strength #57

Open
TedSanne opened this issue May 31, 2022 · 1 comment
Open

Updating a document resets reference strength #57

TedSanne opened this issue May 31, 2022 · 1 comment

Comments

@TedSanne
Copy link

TedSanne commented May 31, 2022

When querying a document all references seem to have the Weak prop on SanityReference set to null.
This in turn seems to be converted into a strong reference when the document is updated.

Example:

var docSet = await _sanity.DocumentSet<Filmomtale>()
                .Include(f => f.Distributor)
            .Where(f => f.Id == id)
            .ExecuteAsync(cancellationToken);

var doc = docSet.Single();

<... update some fields on doc, but leave Distributor reference untouched ....>

await _sanity.DocumentSet<Filmomtale>()
                    .Update(doc)
                    .CommitAsync(cancellationToken: cancellationToken);

Here "Distributor" is a reference to another document type, the schema specifies the reference as weak:

{
			title: 'Distributør',
			name: 'distributor',
			type: 'reference',
			readOnly: false,
			to: [
				{ type: 'distributor' }
			],
			weak: true,
			group: "metadata"
		}

When debugging this I can see that the Weak property on the reference to Distributor is null.
After the document has been updated, Sanity Studio now shows a warning "Reference strength mismatch" for the Distributor field.

Is this a bug, or is there something else I need to do when querying to make sure the reference is returned?

EDIT: I am using 1.5.0 from NuGet

@TedSanne
Copy link
Author

Other weak references that are not .Incude(...) in the query are not affected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant