File tree Expand file tree Collapse file tree 8 files changed +273
-20
lines changed
Expand file tree Collapse file tree 8 files changed +273
-20
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ const dateTimeScalar = new GraphQLScalarType({
3232 } ,
3333} ) ;
3434
35- export const resolvers = {
35+ export const resolvers : GraphQLResolverMap < GraphQLContext > = {
3636 DateTime : dateTimeScalar ,
3737 Query : {
3838 ...userResolvers . Query ,
@@ -48,4 +48,4 @@ export const resolvers = {
4848 Organization : organizationResolvers . Organization ,
4949 OrganizationMember : memberResolvers . OrganizationMember ,
5050 Invitation : invitationResolvers . Invitation ,
51- } as GraphQLResolverMap < GraphQLContext > ;
51+ } ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { v4 as uuid4 } from "uuid";
22import { createAdminClient } from "@/lib/supabase/admin" ;
33import { sendInvitationEmail } from "@/lib/services/email" ;
44import { logger } from "@/lib/logger" ;
5- import type { GraphQLResolverMap } from "@apollo/subgraph/dist/schema-helper/resolverMap " ;
5+ import type { GraphQLResolverModule } from "@/app/api/v1/osograph/utils/types " ;
66import {
77 requireAuthentication ,
88 requireOrgMembership ,
@@ -23,7 +23,7 @@ import {
2323 ServerErrors ,
2424} from "@/app/api/v1/osograph/utils/errors" ;
2525
26- export const invitationResolvers : GraphQLResolverMap < GraphQLContext > = {
26+ export const invitationResolvers : GraphQLResolverModule < GraphQLContext > = {
2727 Query : {
2828 osoApp_invitation : async (
2929 _ : unknown ,
Original file line number Diff line number Diff line change 11import { createAdminClient } from "@/lib/supabase/admin" ;
2- import type { GraphQLResolverMap } from "@apollo/subgraph/dist/schema-helper/resolverMap " ;
2+ import type { GraphQLResolverModule } from "@/app/api/v1/osograph/utils/types " ;
33import {
44 requireAuthentication ,
55 requireOrgMembership ,
@@ -22,7 +22,7 @@ import {
2222 ErrorCode ,
2323} from "@/app/api/v1/osograph/utils/errors" ;
2424
25- export const memberResolvers : GraphQLResolverMap < GraphQLContext > = {
25+ export const memberResolvers : GraphQLResolverModule < GraphQLContext > = {
2626 OrganizationMember : {
2727 __resolveReference : async ( reference : { id : string } ) => {
2828 const supabase = createAdminClient ( ) ;
Original file line number Diff line number Diff line change 11import { createAdminClient } from "@/lib/supabase/admin" ;
2- import type { GraphQLResolverMap } from "@apollo/subgraph/dist/schema-helper/resolverMap " ;
2+ import type { GraphQLResolverModule } from "@/app/api/v1/osograph/utils/types " ;
33import {
44 requireAuthentication ,
55 requireOrgMembership ,
88 type GraphQLContext ,
99} from "@/app/api/v1/osograph/utils/auth" ;
1010
11- export const organizationResolvers : GraphQLResolverMap < GraphQLContext > = {
11+ export const organizationResolvers : GraphQLResolverModule < GraphQLContext > = {
1212 Query : {
1313 osoApp_organization : async (
1414 _ : unknown ,
@@ -27,6 +27,9 @@ export const organizationResolvers: GraphQLResolverMap<GraphQLContext> = {
2727 return getOrganization ( reference . id ) ;
2828 } ,
2929
30+ orgName : ( parent : { org_name : string } ) => parent . org_name ,
31+ createdAt : ( parent : { created_at : string } ) => parent . created_at ,
32+
3033 members : async (
3134 parent : { id : string } ,
3235 _args : unknown ,
Original file line number Diff line number Diff line change 11import { createAdminClient } from "@/lib/supabase/admin" ;
2- import type { GraphQLResolverMap } from "@apollo/subgraph/dist/schema-helper/resolverMap " ;
2+ import type { GraphQLResolverModule } from "@/app/api/v1/osograph/utils/types " ;
33import {
44 getUserProfile ,
55 requireAuthentication ,
66 type GraphQLContext ,
77} from "@/app/api/v1/osograph/utils/auth" ;
88import { UserErrors , ServerErrors } from "@/app/api/v1/osograph/utils/errors" ;
99
10- export const userResolvers : GraphQLResolverMap < GraphQLContext > = {
10+ export const userResolvers : GraphQLResolverModule < GraphQLContext > = {
1111 Query : {
1212 osoApp_me : async ( _ : unknown , _args : unknown , context : GraphQLContext ) => {
1313 const authenticatedUser = requireAuthentication ( context . user ) ;
@@ -64,6 +64,9 @@ export const userResolvers: GraphQLResolverMap<GraphQLContext> = {
6464 return getUserProfile ( reference . id ) ;
6565 } ,
6666
67+ fullName : ( parent : { full_name : string | null } ) => parent . full_name ,
68+ avatarUrl : ( parent : { avatar_url : string | null } ) => parent . avatar_url ,
69+
6770 organizations : async (
6871 parent : { id : string } ,
6972 _args : unknown ,
Original file line number Diff line number Diff line change 1+ import type { GraphQLScalarType } from "graphql" ;
2+ import type { GraphQLResolverMap } from "@apollo/subgraph/dist/schema-helper/resolverMap" ;
3+
4+ /**
5+ * Helper type to determine if a resolver map value is a resolver object
6+ * (i.e., not a scalar or enum).
7+ */
8+ type IsResolverObject < T > = T extends GraphQLScalarType
9+ ? never
10+ : T extends { [ key : string ] : string | number }
11+ ? T extends { [ key : string ] : ( ...args : never [ ] ) => unknown }
12+ ? T
13+ : never
14+ : T ;
15+
16+ /**
17+ * Type for partial GraphQL resolver modules.
18+ * This is the same as `GraphQLResolverMap` but excludes `scalars` and `enums`,
19+ * so it only allows resolver objects (`Query`, `Mutation`, and type resolvers).
20+ */
21+ export type GraphQLResolverModule < TContext = unknown > = {
22+ [ typeName : string ] : IsResolverObject < GraphQLResolverMap < TContext > [ string ] > ;
23+ } ;
Original file line number Diff line number Diff line change 11import { CodegenConfig } from "@graphql-codegen/cli" ;
22import {
33 DAGSTER_GRAPHQL_URL ,
4- // DOMAIN,
4+ DOMAIN ,
55 HASURA_URL ,
66 OSO_API_KEY ,
77} from "@/lib/config" ;
88
9- // const PROTOCOL = DOMAIN.includes("localhost") ? "http" : "https";
10- // const OSO_GRAPH_URL = new URL(
11- // "/api/v1/osograph",
12- // `${PROTOCOL}://${DOMAIN}`,
13- // ).toString();
9+ const PROTOCOL = DOMAIN . includes ( "localhost" ) ? "http" : "https" ;
10+ const OSO_GRAPH_URL = new URL (
11+ "/api/v1/osograph" ,
12+ `${ PROTOCOL } ://${ DOMAIN } ` ,
13+ ) . toString ( ) ;
1414
1515const SCHEMA : Record < string , any > = { } ;
1616SCHEMA [ HASURA_URL ] = {
@@ -19,10 +19,7 @@ SCHEMA[HASURA_URL] = {
1919 } ,
2020} ;
2121SCHEMA [ DAGSTER_GRAPHQL_URL ] = { } ;
22- // TODO(jabolo): Enable this when oso graph is in production
23- // so introspection does not fail (the endpoint is not accessible
24- // until we merge into main for the first time).
25- // SCHEMA[OSO_GRAPH_URL] = {};
22+ SCHEMA [ OSO_GRAPH_URL ] = { } ;
2623const config : CodegenConfig = {
2724 schema : SCHEMA ,
2825 documents : [
You can’t perform that action at this time.
0 commit comments