Skip to content

Conversation

Martinsos
Copy link
Member

@Martinsos Martinsos commented Sep 13, 2025

When calling Operations from the server (instead of the client), you need to pass the information about the authenticated user, if Operations expects it. On client that happens automatically, on server you have to specify it.

You can do that by passing context object, and specifying user field in it. That is what we say in the docs.

However, what was not clear to me (when I was answering a user and reading our docs to figure it out), was what happens with the rest of the context object. If we pass our own context, what about context.entities if Operation needs that -> will that be automatically set for us, so "merged" into the context that we provide, or are we then expected to provide that also, since we provided our own context and therefore took over the "control" of it in our hands?

Turns out, the context we pass will be merged with the "wasp prepared" context, so it is enough to just specify the user and not entities or anything else.

So what I did was add a single sentence to the docs that explains that the rest of the context will be provided automatically.

Clarified instructions for authenticated Queries regarding context object usage.
Copy link

cloudflare-workers-and-pages bot commented Sep 13, 2025

Deploying wasp-docs-on-main with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3993402
Status: ✅  Deploy successful!
Preview URL: https://3ad4052b.wasp-docs-on-main.pages.dev
Branch Preview URL: https://queries-server-use-explanati.wasp-docs-on-main.pages.dev

View logs

@Martinsos Martinsos self-assigned this Sep 17, 2025
@infomiho infomiho requested a review from Copilot October 2, 2025 12:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR clarifies the documentation for server-side query operations by explaining how the context object is handled when calling queries from the server. The change addresses confusion about whether developers need to provide the entire context object or just the user field.

  • Added clarification that only the user field needs to be specified in the context object
  • Explained that other context parts like Entities are automatically injected

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@infomiho infomiho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition!

@Martinsos Martinsos merged commit bea592b into release Oct 2, 2025
2 of 3 checks passed
@Martinsos Martinsos deleted the queries-server-use-explanation branch October 2, 2025 12:09
@Martinsos Martinsos restored the queries-server-use-explanation branch October 2, 2025 12:20
@Martinsos Martinsos deleted the queries-server-use-explanation branch October 2, 2025 12:23
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

Successfully merging this pull request may close these issues.

2 participants