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

Allow descriptions schema #1305

Merged
merged 6 commits into from
Jun 4, 2024
Merged

Allow descriptions schema #1305

merged 6 commits into from
Jun 4, 2024

Conversation

noah-paige
Copy link
Contributor

Feature or Bugfix

  • Enhancement

Detail

  • Allow dataset admin role glue permissions for dataset crawler

  • Allow GQL Types, Arguments, Inputs, and Fields to take in description instance variable and write GQL schema including the description docstring

Relates

  • Data.all SDK/CLI

Security

Please answer the questions below briefly where applicable, or write N/A. Based on
OWASP 10.

  • Does this PR introduce or modify any input fields or queries - this includes
    fetching data from storage outside the application (e.g. a database, an S3 bucket)?
    • Is the input sanitized?
    • What precautions are you taking before deserializing the data you consume?
    • Is injection prevented by parametrizing queries?
    • Have you ensured no eval or similar functions are used?
  • Does this PR introduce any functionality or component that requires authorization?
    • How have you ensured it respects the existing AuthN/AuthZ mechanisms?
    • Are you logging failed auth attempts?
  • Are you using or adding any cryptographic features?
    • Do you use a standard proven implementations?
    • Are the used keys controlled by the customer? Where are they stored?
  • Are you introducing any new policies/roles/users?
    • Have you used the least-privilege principle? How?

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

backend/dataall/base/api/gql/graphql_argument.py Outdated Show resolved Hide resolved
if isinstance(self.type, Enum):
return f'{self.name} : {self.type.name}'
return f'{description_str}{self.name} : {self.type.name}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, do we want to store \n in description itself?
IMHO, it's better to format it in place
'{description_str}\n{self.name} : {self.type.name}'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well we do not need \n if there is a description - so the new line is tied to the description a bit

I have not played around with how descriptions can be interpreted - I can play around a bit to see if can keep all on same line but if not I will keep it as is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my research - the standard seems to be adding comments on a new line above the type or argument you are describing (ex: https://medium.com/@krishnaregmi/how-to-write-comments-in-a-graphql-schema-to-enhance-auto-generated-documentation-c0047125ea24)

I think best to follow the same

backend/dataall/base/api/gql/graphql_field.py Outdated Show resolved Hide resolved
backend/dataall/base/api/gql/graphql_input.py Outdated Show resolved Hide resolved
@@ -21,7 +21,7 @@

SearchGlossary = gql.QueryField(
name='searchGlossary',
doc='Search glossary ',
description='Search glossary ',
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, after the transformation described above, we will have both space and \n.
Is it ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure I follow but the extra space is not a problem - will have a later PR that adds descriptions to all of our GQL queries, mutations, etc. and can clean up this description then

@noah-paige noah-paige merged commit e91b31b into main Jun 4, 2024
9 checks passed
@dlpzx dlpzx deleted the allow-descriptions-schema branch June 26, 2024 09:26
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