-
Notifications
You must be signed in to change notification settings - Fork 74
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: generate api code #269
Conversation
🦋 Changeset detectedLatest commit: 138da96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
689bdf3
to
faea5eb
Compare
faea5eb
to
77feaa6
Compare
fff9686
to
4963b85
Compare
4963b85
to
4af3bd8
Compare
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.
looks good.
packages/model-generator/API.md
Outdated
// @public (undocumented) | ||
export type GeneratedOutput = { | ||
[filename: string]: string; | ||
}; |
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 seems to be unused. please hide.
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 is the return type of generateApiCode
.
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.
In that case shouldn't generateApiCode
just return GenerationResult
like the wrapped operations do?
Do we have use case where in-memory representation would be consumed?
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.
I'll update to GenerationResult
. The in-memory functionality was a requirement from Rene and is how Al's PR is built https://github.com/aws-amplify/samsara-cli/pull/265/files#diff-dcea9a2f178bf1deb339fd2cc2aa95b9cf136b2f32a660c1c3501f8bd62c399dR30-R57
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.
Al's PR can use GenerationResult.writeToDirectory()
API. Which was created for that purpose.
@alharris-at do you know why PMs want in-memory representation? Can this be descoped for now until we know what is the use case?
Regardless of whether it's a must or not the GenerationResult
was a place to add Record<string, string>
prop to provide that. But if we don't know use case we should hold.
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.
I'm fine chopping this out for now.
packages/model-generator/API.md
Outdated
// @public (undocumented) | ||
export type GenerationResult = { | ||
writeToDirectory: (directoryPath: string) => Promise<void>; | ||
operations: Record<string, string>; |
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 we have a use case for this?
If not please hide.
@@ -12,7 +12,7 @@ export class AppsyncGraphqlGenerationResult implements GenerationResult { | |||
* @param operations A record of FileName to FileContent | |||
* in the format of Record<string,string> | |||
*/ | |||
constructor(private operations: ClientOperations) {} | |||
constructor(public operations: ClientOperations) {} |
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.
why ?
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 is so that generateApiCode
can return the generation results without writing to the file system.
maxDepth: 3, | ||
typenameIntrospection: true, |
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.
Will dropping these defaults impact form gen, or is Spencer already passing these in?
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.
I don't think this is being used by the form generation yet. @sdstolworthy
target: props.typeTarget, | ||
multipleSwiftFiles: props.multipleSwiftFiles, | ||
}); | ||
return { ...documents, ...types }; |
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.
I need to fix this to be a new combined GenerationResult
.
// @public | ||
export const generateApiCode: (props: GenerateApiCodeProps) => Promise<GenerationResult>; | ||
|
||
// @public (undocumented) | ||
export type GenerateApiCodeProps = GenerateOptions & BackendIdentifier & { | ||
credentialProvider: AwsCredentialIdentityProvider; | ||
}; |
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.
One more suggestion.
Rest of APIs are explicit about Graphql
Should we use generateGraphqlApiCode
(and similar in props/return) ?
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.
Rene wanted customer facing APIs to use "API" over "Graphql". We'll be syncing with him on naming next week to finalize.
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.
Yeah, we'll be able to close on this by EOD Monday, but I wouldn't make it block this, since we want this in for the pentest ready date, which is also monday (easy to change)
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.
ok
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.
Also. Then
If this is customer facing I suggest to consider moving other types to namespaces.
So that import * as generator from '@aws-amplify/model-generator'
does not cause explosion in IDE when customer types generator.
.
For example other types can be moved to @aws-amplify/model-generator/documents
@aws-amplify/model-generator/types
what not. We do that in other packages that are customer facing like here:
https://github.com/aws-amplify/samsara-cli/blob/4fd18b126ba075d054ddc4b34859e67e519355e5/packages/client-config/package.json#L8-L18
Issue #, if available:
Description of changes:
generateAPICode
).createGraphqlDocumentGenerator
andcreateGraphqlTypesGenerator
to use backendIdentifier and credentialProvider.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.