-
Notifications
You must be signed in to change notification settings - Fork 122
Console 1493 schema explorer displaying argument descriptions #7282
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
Open
jonathanawesome
wants to merge
21
commits into
main
Choose a base branch
from
console-1493-schema-explorer-displaying-argument-descriptions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3b48b12
lock file
jonathanawesome 56446de
rename hasUnusedArguments to hasArguments
jonathanawesome ab246ec
Merge branch 'main' into console-1493-schema-explorer-displaying-argu…
jonathanawesome 3ca8821
extract shared filtering logic to hook, pull out - fields and -argume…
jonathanawesome 7fe9a6b
refactor arguments list toggle to descriptions visible toggle, keep l…
jonathanawesome 1c172fe
clean up conditionals to match /explorer/*
jonathanawesome 9c77707
lock file
jonathanawesome 159ec1a
fix backwards switch
jonathanawesome e4b2798
set default descriptionsVisible to false
jonathanawesome d62cc36
remove collapsed props
jonathanawesome 13ba6b4
gemini catches one!
jonathanawesome 37fd0d8
Merge branch 'main' into console-1493-schema-explorer-displaying-argu…
jonathanawesome d1d8619
enhance fed seed schema arguments with descriptions
jonathanawesome b012343
lock file
jonathanawesome bf67aa6
Merge branch 'main' into console-1493-schema-explorer-displaying-argu…
jonathanawesome 70c54b3
lock file
jonathanawesome df36bfb
bump argument type font weight
jonathanawesome 7f81933
Merge branch 'main' into console-1493-schema-explorer-displaying-argu…
jonathanawesome b7f3acc
Merge branch 'main' into console-1493-schema-explorer-displaying-argu…
jonathanawesome cdfe84f
fix composition errors...why didn't this flag before?
jonathanawesome 02d1078
prettier --write
jonathanawesome File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
425 changes: 31 additions & 394 deletions
425
packages/web/app/src/components/target/explorer/common.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/web/app/src/components/target/explorer/graphql-arguments.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { FragmentType, graphql, useFragment } from '@/gql'; | ||
| import { DeprecationNote, Description, GraphQLTypeAsLink, LinkToCoordinatePage } from './common'; | ||
| import { useDescriptionsVisibleToggle } from './provider'; | ||
|
|
||
| export const GraphQLArguments_ArgumentFragment = graphql(` | ||
| fragment GraphQLArguments_ArgumentFragment on GraphQLArgument { | ||
| name | ||
| description | ||
| type | ||
| isDeprecated | ||
| deprecationReason | ||
| } | ||
| `); | ||
|
|
||
| export function GraphQLArguments(props: { | ||
| parentCoordinate: string; | ||
| args: FragmentType<typeof GraphQLArguments_ArgumentFragment>[]; | ||
| styleDeprecated: boolean; | ||
| organizationSlug: string; | ||
| projectSlug: string; | ||
| targetSlug: string; | ||
| }) { | ||
| const args = useFragment(GraphQLArguments_ArgumentFragment, props.args); | ||
|
|
||
| const { isDescriptionsVisible } = useDescriptionsVisibleToggle(); | ||
|
|
||
| return ( | ||
| <span className="ml-1 text-gray-400"> | ||
| <span>(</span> | ||
| <div className="pl-4 text-gray-300"> | ||
| {args.map(arg => { | ||
| const coordinate = `${props.parentCoordinate}.${arg.name}`; | ||
| return ( | ||
| <div key={arg.name}> | ||
| <DeprecationNote | ||
| styleDeprecated={props.styleDeprecated} | ||
| deprecationReason={arg.deprecationReason} | ||
| > | ||
| <LinkToCoordinatePage | ||
| organizationSlug={props.organizationSlug} | ||
| projectSlug={props.projectSlug} | ||
| targetSlug={props.targetSlug} | ||
| coordinate={coordinate} | ||
| > | ||
| {arg.name} | ||
| </LinkToCoordinatePage> | ||
| </DeprecationNote> | ||
| {': '} | ||
| <GraphQLTypeAsLink | ||
| organizationSlug={props.organizationSlug} | ||
| projectSlug={props.projectSlug} | ||
| targetSlug={props.targetSlug} | ||
| type={arg.type} | ||
| /> | ||
| {arg.description && isDescriptionsVisible && ( | ||
| <Description description={arg.description} /> | ||
| )} | ||
| </div> | ||
| ); | ||
| })} | ||
| </div> | ||
| <span>)</span> | ||
| </span> | ||
| ); | ||
| } |
155 changes: 155 additions & 0 deletions
155
packages/web/app/src/components/target/explorer/graphql-fields.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,155 @@ | ||
| import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; | ||
| import { FragmentType, graphql, useFragment } from '@/gql'; | ||
| import { | ||
| DeprecationNote, | ||
| Description, | ||
| GraphQLTypeAsLink, | ||
| GraphQLTypeCardListItem, | ||
| LinkToCoordinatePage, | ||
| SchemaExplorerUsageStats, | ||
| } from './common'; | ||
| import { GraphQLArguments } from './graphql-arguments'; | ||
| import { SupergraphMetadataList } from './super-graph-metadata'; | ||
| import { useExplorerFieldFiltering } from './utils'; | ||
|
|
||
| const GraphQLFields_FieldFragment = graphql(` | ||
| fragment GraphQLFields_FieldFragment on GraphQLField { | ||
| name | ||
| description | ||
| type | ||
| isDeprecated | ||
| deprecationReason | ||
| usage { | ||
| total | ||
| ...SchemaExplorerUsageStats_UsageFragment | ||
| } | ||
| args { | ||
| ...GraphQLArguments_ArgumentFragment | ||
| } | ||
| supergraphMetadata { | ||
| ...SupergraphMetadataList_SupergraphMetadataFragment | ||
| } | ||
| } | ||
| `); | ||
|
|
||
| export function GraphQLFields(props: { | ||
| typeName: string; | ||
| fields: Array<FragmentType<typeof GraphQLFields_FieldFragment>>; | ||
| totalRequests?: number; | ||
| collapsed?: boolean; | ||
| targetSlug: string; | ||
| projectSlug: string; | ||
| organizationSlug: string; | ||
| warnAboutUnusedArguments: boolean; | ||
| warnAboutDeprecatedArguments: boolean; | ||
| styleDeprecated: boolean; | ||
| }) { | ||
| const { totalRequests } = props; | ||
| const fieldsFromFragment = useFragment(GraphQLFields_FieldFragment, props.fields); | ||
|
|
||
| const sortedAndFilteredFields = useExplorerFieldFiltering({ | ||
| fields: fieldsFromFragment, | ||
| }); | ||
|
|
||
| return ( | ||
| <TooltipProvider delayDuration={0}> | ||
| <div className="flex flex-col"> | ||
| {sortedAndFilteredFields.map((field, i) => { | ||
| const coordinate = `${props.typeName}.${field.name}`; | ||
| const isUsed = field.usage.total > 0; | ||
| const hasArguments = field.args.length > 0; | ||
| const showsUnusedSchema = typeof totalRequests !== 'number'; | ||
| const isDeprecated = field.isDeprecated; | ||
|
|
||
| return ( | ||
| <GraphQLTypeCardListItem key={field.name} index={i}> | ||
| <div className="w-full"> | ||
| <div className="flex w-full flex-row items-baseline justify-between"> | ||
| <div> | ||
| {props.warnAboutUnusedArguments && | ||
| isUsed && | ||
| hasArguments && | ||
| showsUnusedSchema && ( | ||
| <Tooltip> | ||
| <TooltipContent> | ||
| This field is used but the presented arguments are not. | ||
| </TooltipContent> | ||
| <TooltipTrigger> | ||
| <span className="mr-1 text-sm text-orange-500">*</span> | ||
| </TooltipTrigger> | ||
| </Tooltip> | ||
| )} | ||
| {props.warnAboutDeprecatedArguments && !isDeprecated && ( | ||
| <Tooltip> | ||
| <TooltipContent> | ||
| This field is not deprecated but the presented arguments are. | ||
| </TooltipContent> | ||
| <TooltipTrigger> | ||
| <span className="mr-1 text-sm text-orange-500">*</span> | ||
| </TooltipTrigger> | ||
| </Tooltip> | ||
| )} | ||
| <DeprecationNote | ||
| styleDeprecated={props.styleDeprecated} | ||
| deprecationReason={field.deprecationReason} | ||
| > | ||
| <LinkToCoordinatePage | ||
| organizationSlug={props.organizationSlug} | ||
| projectSlug={props.projectSlug} | ||
| targetSlug={props.targetSlug} | ||
| coordinate={coordinate} | ||
| className="font-semibold" | ||
| > | ||
| {field.name} | ||
| </LinkToCoordinatePage> | ||
| </DeprecationNote> | ||
| {field.args.length > 0 && ( | ||
| <GraphQLArguments | ||
| organizationSlug={props.organizationSlug} | ||
| projectSlug={props.projectSlug} | ||
| targetSlug={props.targetSlug} | ||
| styleDeprecated={props.styleDeprecated} | ||
| parentCoordinate={coordinate} | ||
| args={field.args} | ||
| /> | ||
| )} | ||
| <span className="mr-1">:</span> | ||
| <GraphQLTypeAsLink | ||
| organizationSlug={props.organizationSlug} | ||
| projectSlug={props.projectSlug} | ||
| targetSlug={props.targetSlug} | ||
| className="font-semibold text-gray-300" | ||
| type={field.type} | ||
| /> | ||
| </div> | ||
| <div className="flex flex-row items-center"> | ||
| {field.supergraphMetadata && ( | ||
| <div className="ml-1"> | ||
| <SupergraphMetadataList | ||
| targetSlug={props.targetSlug} | ||
| projectSlug={props.projectSlug} | ||
| organizationSlug={props.organizationSlug} | ||
| supergraphMetadata={field.supergraphMetadata} | ||
| /> | ||
| </div> | ||
| )} | ||
| {typeof totalRequests === 'number' && ( | ||
| <SchemaExplorerUsageStats | ||
| totalRequests={totalRequests} | ||
| usage={field.usage} | ||
| targetSlug={props.targetSlug} | ||
| projectSlug={props.projectSlug} | ||
| organizationSlug={props.organizationSlug} | ||
| /> | ||
| )} | ||
| </div> | ||
| </div> | ||
| {field.description && <Description description={field.description} />} | ||
| </div> | ||
| </GraphQLTypeCardListItem> | ||
| ); | ||
| })} | ||
| </div> | ||
| </TooltipProvider> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.