0

I tried to get all users from Azure AD with Hire date > 2012-12-31T23:59:59.

return graph.users
      .select("givenName", "surname", "employeeHireDate", "id", "mail", "jobTitle")
      .filter("employeeHireDate ge 2012-12-31T23:59:59Z")
      .count
      .get()
      .then((usersList) => ....)

I found out that the ConsistencyLevel header required for advanced queries.

ConsistencyLevel:eventual

How can I set this Header params in my graph query?

Using: @pnp/pnpjs: ^2.0.13

1 Answer 1

0

Try adding ConsistencyLevel header like this:

import { graphfi, ConsistencyLevel } from "@pnp/graph";
import "@pnp/graph/users";

const graph = graphfi().using(ConsistencyLevel());

await graph.users();

Documentation: @pnp/graph: behaviors - ConsistencyLevel

2
  • I tried, but have an error on setup method. (Property 'setup' does not exist on type 'GraphFI'). ` import { graphfi, ConsistencyLevel } from "@pnp/graph"; import "@pnp/graph/users"; public onInit(): Promise<void> { const graph = graphfi().using(ConsistencyLevel()); return super.onInit().then(_ => { graph.setup({ spfxContext: this.context as any }); }); } ` "@pnp/graph": "^3.13.0",
    – Propool
    Apr 10, 2023 at 14:23
  • Follow this documentation and see if it helps: pnp.github.io/pnpjs/transition-guide Apr 10, 2023 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.