-
Notifications
You must be signed in to change notification settings - Fork 219
Initial FDC resolver support in functions SDK. #1784
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @rosalyntan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces foundational support for Firebase Data Connect (FDC) resolvers within the Firebase Functions SDK. It provides a new entry point, Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces initial support for Firebase Data Connect (FDC) resolvers via a new onGraphRequest function. This allows developers to create GraphQL endpoints. My review focuses on the implementation of onGraphRequest and its associated options. I've identified a critical issue with how optional dependencies are handled, which will cause runtime errors. I've also found some bugs related to handling server options, such as ignoring the customizable path and schema file path. Additionally, there are some areas for improvement in the options interface and a hardcoded value that needs clarification.
src/v2/providers/dataconnect.ts
Outdated
| if (!opts.resolvers.query && !opts.resolvers.mutation) { | ||
| throw new Error("At least one query or mutation resolver must be provided."); | ||
| } | ||
| const apolloResolvers: { [key: string]: any } = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit* curious if this type can be tightened to match expecations of ApolloServer instead of it being a generic object.
also nit, I usually prefer using Record, e.g. Record<string, any>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm it looks like this should be GraphqlResolvers type we defined below, with the change that query -> Query and mutation -> Mutation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason we're not directly using ApolloServer's types here is for future extensibility, for example the developer could pass in an option to use the graphql-http library instead.
| path?: string; | ||
| /** A map of functions that populate data for individual GraphQL schema fields. */ | ||
| resolvers: GraphqlResolvers; | ||
| // TODO: Add a field for a context function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want to leave this todo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't included in the original API proposal, so wanted to run it by you and the council (maybe in an email follow-up) before adding this field.
| } | ||
|
|
||
| /** Options for configuring the GraphQL server. */ | ||
| export interface GraphqlServerOptions extends HttpsOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may have noticed that most of trigger options ends up repeating the common options... this is because we learned that our reference doc generation doesn't show the full range of options that's available in the parent type (in this case HttpOptions).
For better reference docs, we might want to repeat all the available options for the graphql server options here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So looking at https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.https.httpsoptions.md, it looks like it does link to the parent type which I think seems sufficient (and I think this also makes the GraphQL-specific options more visible to developers).
On a related note, if we're ignoring CORS configuration with these options, should I do something like Omit<GlobalOptions, "cors"> here?
Description
Implement the
onGraphRequesthelper function for building a Firebase Data Connect resolver detailed in go/fdc-webhooks-functions-api.Code sample