Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,358 changes: 3,189 additions & 3,169 deletions connect-go/gen/proto/wg/cosmo/platform/v1/platform.pb.go

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions connect/src/wg/cosmo/platform/v1/platform_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16032,6 +16032,16 @@ export class GetFieldUsageRequest extends Message<GetFieldUsageRequest> {
*/
featureFlagName?: string;

/**
* @generated from field: bool is_argument = 9;
*/
isArgument = false;

/**
* @generated from field: bool is_input = 10;
*/
isInput = false;

constructor(data?: PartialMessage<GetFieldUsageRequest>) {
super();
proto3.util.initPartial(data, this);
Expand All @@ -16048,6 +16058,8 @@ export class GetFieldUsageRequest extends Message<GetFieldUsageRequest> {
{ no: 6, name: "dateRange", kind: "message", T: DateRange },
{ no: 7, name: "namespace", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 8, name: "feature_flag_name", kind: "scalar", T: 9 /* ScalarType.STRING */, opt: true },
{ no: 9, name: "is_argument", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 10, name: "is_input", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): GetFieldUsageRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export function getFieldUsage(
namedType: req.namedType,
range: req.range,
dateRange: dr,
isArgument: req.isArgument ?? false, // default to false if not provided
isInput: req.isInput ?? false, // default to false if not provided
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export class UsageRepository {
dateRange?: DateRange;
organizationId: string;
federatedGraphId: string;
isArgument: boolean;
isInput: boolean;
}) {
const timeFilters = parseTimeFilters(input.dateRange, input.range);

Expand All @@ -177,6 +179,13 @@ export class UsageRepository {
params.namedType = input.namedType;
whereSql += ` AND NamedType = {namedType:String}`;
}

params.isArgument = input.isArgument;
whereSql += ` AND IsArgument = {isArgument:Boolean}`;

params.isInput = input.isInput;
whereSql += ` AND IsInput = {isInput:Boolean}`;

whereSql += ` AND IsIndirectFieldUsage = false AND IsNull = false`;

const [requestSeries, clients, meta] = await Promise.all([
Expand Down
2 changes: 2 additions & 0 deletions proto/wg/cosmo/platform/v1/platform.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,8 @@ message GetFieldUsageRequest {
DateRange dateRange = 6;
string namespace = 7;
optional string feature_flag_name = 8;
bool is_argument = 9;
bool is_input = 10;
}

message ClientWithOperations {
Expand Down
4 changes: 4 additions & 0 deletions studio/src/components/analytics/field-usage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ export const FieldUsageSheet = () => {
const graph = useContext(GraphContext);
const featureFlagName = router.query.featureFlag as string;

const category = router.query.category as string;
const isInput = category === "inputs";

const { data, error, isLoading, refetch } = useQuery(
getFieldUsage,
{
Expand All @@ -370,6 +373,7 @@ export const FieldUsageSheet = () => {
end: formatISO(dateRange.end),
},
featureFlagName,
isInput,
},
{
enabled: !!showUsage && !!graph?.graph?.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ const FieldUsageColumn = ({
const graph = useContext(GraphContext);
const router = useRouter();
const featureFlagName = router.query.featureFlag as string;
const { ast } = useContext(ExplorerContext);

const category = getCategoryForType(ast, typename);
const isInput = category === "inputs";

const { data: usageData } = useQuery(
getFieldUsage,
Expand All @@ -208,6 +212,7 @@ const FieldUsageColumn = ({
end: formatISO(dateRange.end),
},
featureFlagName,
isInput,
},
{
enabled: !!graph?.graph?.name,
Expand Down Expand Up @@ -494,7 +499,8 @@ const Type = (props: {
endLineNo?: number;
}) => {
const router = useRouter();
const isAuthenticatedType = props.authenticated || !!props.requiresScopes?.length;
const isAuthenticatedType =
props.authenticated || !!props.requiresScopes?.length;

return (
<div className="flex h-full flex-col">
Expand Down Expand Up @@ -546,7 +552,12 @@ const Type = (props: {

{props.requiresScopes?.length && (
<AuthenticatedScopes isType scopes={props.requiresScopes} asChild>
<button type="button" className={badgeVariants({ className: "w-max" })}>View scopes</button>
<button
type="button"
className={badgeVariants({ className: "w-max" })}
>
View scopes
</button>
</AuthenticatedScopes>
)}
</div>
Expand Down Expand Up @@ -763,7 +774,11 @@ const DeprecatedBadge = ({ reason }: { reason: string | undefined | null }) => {
);
};

const AuthenticatedBadge = ({ isType, authenticated, requiresScopes }: {
const AuthenticatedBadge = ({
isType,
authenticated,
requiresScopes,
}: {
isType: boolean;
authenticated?: boolean;
requiresScopes?: string[][];
Expand All @@ -778,7 +793,9 @@ const AuthenticatedBadge = ({ isType, authenticated, requiresScopes }: {
<LockClosedIcon className="h-3 w-3 flex-shrink-0" />
Authenticated
</span>
{!!requiresScopes?.length && <AuthenticatedScopes isType={isType} scopes={requiresScopes} />}
{!!requiresScopes?.length && (
<AuthenticatedScopes isType={isType} scopes={requiresScopes} />
)}
</p>
);
};
Expand All @@ -797,17 +814,18 @@ const AuthenticatedScopes = ({
return (
<Popover>
<PopoverTrigger asChild={asChild}>
{children
? children
: (
<Button variant="link" size="sm" className="h-auto p-0">
View scopes
</Button>
)}
{children ? (
children
) : (
<Button variant="link" size="sm" className="h-auto p-0">
View scopes
</Button>
)}
</PopoverTrigger>
<PopoverContent className="px-0">
<div className="mb-3 border-b border-border px-4 pb-3">
The following scope(s) are required to access this {isType ? "type" : "field"}:
The following scope(s) are required to access this{" "}
{isType ? "type" : "field"}:
</div>

{scopes
Expand Down Expand Up @@ -1408,7 +1426,9 @@ const SchemaExplorerPage: NextPageWithLayout = () => {
const user = useUser();

const organizationSlug = user?.currentOrganization.slug;
const { namespace: { name: namespace } } = useWorkspace();
const {
namespace: { name: namespace },
} = useWorkspace();
const graphName = router.query.slug as string;
const selectedCategory = (router.query.category as string) ?? "query";
const typename = router.query.typename as string;
Expand All @@ -1431,9 +1451,18 @@ const SchemaExplorerPage: NextPageWithLayout = () => {
const { ast, doc, isParsing } = useParseSchema(schema);
const parsedTypes = useMemo(() => (doc ? getParsedTypes(doc) : []), [doc]);

const typeCounts = useMemo(() => (ast ? getTypeCounts(ast) : undefined), [ast],);
const [deprecatedTypesCount, deprecatedTypes] = useMemo(() => getDeprecatedTypes(parsedTypes), [parsedTypes]);
const [authenticatedTypesCount, authenticatedTypes] = useMemo(() => getAuthenticatedTypes(parsedTypes), [parsedTypes]);
const typeCounts = useMemo(
() => (ast ? getTypeCounts(ast) : undefined),
[ast],
);
const [deprecatedTypesCount, deprecatedTypes] = useMemo(
() => getDeprecatedTypes(parsedTypes),
[parsedTypes],
);
const [authenticatedTypesCount, authenticatedTypes] = useMemo(
() => getAuthenticatedTypes(parsedTypes),
[parsedTypes],
);

const isLoadingAST = isLoading || isParsing;

Expand Down
Loading