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

nit: add rate limit extension example #1125

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbilello
Copy link

@sbilello sbilello commented Nov 6, 2024

Add Rate Limit Extension Example

Copy link

linux-foundation-easycla bot commented Nov 6, 2024

CLA Signed


The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Nov 6, 2024

Deploy Preview for graphql-spec-draft ready!

Name Link
🔨 Latest commit 626261f
🔍 Latest deploy log https://app.netlify.com/sites/graphql-spec-draft/deploys/6733e3fe73c3900008675424
😎 Deploy Preview https://deploy-preview-1125--graphql-spec-draft.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@benjie
Copy link
Member

benjie commented Nov 7, 2024

Generally it's good practice to namespace the top fields in extensions to avoid conflicts, since the meaning is effectively granted to them by the entire ecosystem as a whole with no real governing documents/registry. For example, this rateLimit might be confused by some tooling with a different rateLimit format and result in errors. Instead: sb_rateLimit would be safer, or even extensions:{sb:{rateLimit:{...}}}.

Out of interest, what motivated this addition in particular?

@sbilello
Copy link
Author

@benjie I've revised the example to better demonstrate how developers can implement rate-limiting using the extensions. Could you take a look please?
Thanks

Comment on lines +54 to +61
{
"customNamespace" : {
"requestRate": 2,
"remaining": 98,
"retryAfterMs": 0,
"resetAfterMs": 1985
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This wasn't valid JSON since it had {{ ... }}

Suggested change
{
"customNamespace" : {
"requestRate": 2,
"remaining": 98,
"retryAfterMs": 0,
"resetAfterMs": 1985
}
}
"customNamespace": {
"requestRate": 2,
"remaining": 98,
"retryAfterMs": 0,
"resetAfterMs": 1985
}

@benjie
Copy link
Member

benjie commented Nov 21, 2024

I'm not convinced that the GraphQL spec needs an example of using the extensions property. I'll leave this open in case others feel otherwise.

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