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

feat: flattened context #555

Merged
merged 4 commits into from
Jan 22, 2024
Merged

feat: flattened context #555

merged 4 commits into from
Jan 22, 2024

Conversation

Natoandro
Copy link
Contributor

@Natoandro Natoandro commented Jan 16, 2024

Flatten profile fields in the context.

So instead of

{
    provider: 'github',
    accessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
    refreshToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    refreshAt: 1704717676,
    profile: { id: '43663718' },
    exp: 1707280877,
    iat: 1704688876
}

we would have:

{
    provider: 'github',
    accessToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
    refreshToken: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    refreshAt: 1704717676,
    'profile.id': '43663718',
    exp: 1707280877,
    iat: 1704688876
 }

Motivation and context

It was impossible to get the nested id into a from_context injection.
Now we can inject .from_context("profile.id").

Migration notes

Checklist

  • The change come with new or modified tests
  • Hard-to-understand functions have explanatory comments
  • End-user documentation is updated to reflect the change

Copy link
Contributor

@michael-0acf4 michael-0acf4 left a comment

Choose a reason for hiding this comment

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

How about enabling dot notation directly from context? I think it is best if we let the object as it is.
We split by the dots and walk the path iteratively, this should preserve compatibility with the current context implementation. wdyt?
Ref: https://github.com/metatypedev/metatype/blob/main/typegate/src/engine/planner/args.ts#L624

@zifeo
Copy link
Member

zifeo commented Jan 16, 2024

@Natoandro adding to what @afmika is suggested, I believe this is on the app layer. I expect that the user of those auth methods write their own profiler function in deno (or else) that rewrite the context as they need and enrich it with the permissions they needed

@Natoandro Natoandro merged commit 020a27f into main Jan 22, 2024
9 checks passed
@Natoandro Natoandro deleted the feat/flat-context-2 branch January 22, 2024 13:22
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.

4 participants