Skip to content

Commit

Permalink
fix: fix up version incompat
Browse files Browse the repository at this point in the history
  • Loading branch information
sjungling committed Oct 13, 2022
1 parent c0f8024 commit 10f9618
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 541 deletions.
41 changes: 24 additions & 17 deletions api/@types/resolvers.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type RequireFields<T, K extends keyof T> = { [X in Exclude<keyof T, K>]?: T[X] } & { [P in K]-?: NonNullable<T[P]> };
export type RequireFields<T, K extends keyof T> = Omit<T, K> & { [P in K]-?: NonNullable<T[P]> };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
_FieldSet: any;
DateTime: any;
_FieldSet: any;
};






export type Astronaut = {
__typename?: 'Astronaut';
firstName: Scalars['String'];
Expand All @@ -32,6 +28,12 @@ export type Astronaut = {

export type AstronautResult = Astronaut | NotFound;

export enum Mission_Status_Enum {
Aborted = 'ABORTED',
Canceled = 'CANCELED',
Completed = 'COMPLETED',
Failed = 'FAILED'
}

export type Mission = {
__typename?: 'Mission';
Expand Down Expand Up @@ -60,13 +62,6 @@ export type Mission = {
status: Mission_Status_Enum;
};

export enum Mission_Status_Enum {
Aborted = 'ABORTED',
Canceled = 'CANCELED',
Completed = 'COMPLETED',
Failed = 'FAILED'
}

export type MissionResult = Mission | NotFound;

export type NotFound = {
Expand All @@ -91,7 +86,7 @@ export type Query = {


export type QueryAstronautArgs = {
id?: Maybe<Scalars['Int']>;
id?: InputMaybe<Scalars['Int']>;
};


Expand All @@ -103,6 +98,17 @@ export type QueryMissionArgs = {

export type ResolverTypeWrapper<T> = Promise<T> | T;

export type ReferenceResolver<TResult, TReference, TContext> = (
reference: TReference,
context: TContext,
info: GraphQLResolveInfo
) => Promise<TResult> | TResult;

type ScalarCheck<T, S> = S extends true ? T : NullableCheck<T, S>;
type NullableCheck<T, S> = Maybe<T> extends T ? Maybe<ListCheck<NonNullable<T>, S>> : ListCheck<T, S>;
type ListCheck<T, S> = T extends (infer U)[] ? NullableCheck<U, S>[] : GraphQLRecursivePick<T, S>;
export type GraphQLRecursivePick<T, S> = { [K in keyof T & keyof S]: ScalarCheck<T[K], S[K]> };


export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
Expand Down Expand Up @@ -174,8 +180,8 @@ export type ResolversTypes = {
DateTime: ResolverTypeWrapper<Scalars['DateTime']>;
ID: ResolverTypeWrapper<Scalars['ID']>;
Int: ResolverTypeWrapper<Scalars['Int']>;
Mission: ResolverTypeWrapper<Mission>;
MISSION_STATUS_ENUM: Mission_Status_Enum;
Mission: ResolverTypeWrapper<Mission>;
MissionResult: ResolversTypes['Mission'] | ResolversTypes['NotFound'];
NotFound: ResolverTypeWrapper<NotFound>;
Query: ResolverTypeWrapper<{}>;
Expand Down Expand Up @@ -214,6 +220,7 @@ export interface DateTimeScalarConfig extends GraphQLScalarTypeConfig<ResolversT
}

export type MissionResolvers<ContextType = any, ParentType extends ResolversParentTypes['Mission'] = ResolversParentTypes['Mission']> = {
__resolveReference?: ReferenceResolver<Maybe<ResolversTypes['Mission']>, { __typename: 'Mission' } & GraphQLRecursivePick<ParentType, {"mission":true}>, ContextType>;
astronauts?: Resolver<Array<ResolversTypes['Astronaut']>, ParentType, ContextType>;
commandModule?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
duration?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
Expand All @@ -237,7 +244,7 @@ export type NotFoundResolvers<ContextType = any, ParentType extends ResolversPar
};

export type QueryResolvers<ContextType = any, ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']> = {
astronaut?: Resolver<ResolversTypes['AstronautResult'], ParentType, ContextType, RequireFields<QueryAstronautArgs, never>>;
astronaut?: Resolver<ResolversTypes['AstronautResult'], ParentType, ContextType, Partial<QueryAstronautArgs>>;
astronauts?: Resolver<Array<Maybe<ResolversTypes['Astronaut']>>, ParentType, ContextType>;
hello?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
mission?: Resolver<ResolversTypes['MissionResult'], ParentType, ContextType, RequireFields<QueryMissionArgs, 'id'>>;
Expand Down
Binary file modified api/db/apollo.sqlite3
Binary file not shown.
32 changes: 15 additions & 17 deletions api/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
import { ApolloServer } from "apollo-server-micro";
import { buildFederatedSchema } from "@apollo/federation";
import { ApolloServerPluginInlineTraceDisabled } from "apollo-server-core";
import { typeDefs, resolvers } from "./merge-packages";
import { dataSources } from "./data-sources/";
import cors from "micro-cors";
import { buildSubgraphSchema } from "@apollo/subgraph";
const corsHandler = cors({
allowMethods: ["OPTIONS", "POST", "GET"],
allowHeaders: ["*"],
});

const apolloServer = new ApolloServer({
schema: buildFederatedSchema({ typeDefs, resolvers }),
dataSources,
playground: true,
introspection: true,
cacheControl: {
defaultMaxAge: 300,
},
plugins: [ApolloServerPluginInlineTraceDisabled()],
});

export const config = {
api: {
bodyParser: false,
},
};

const handler = apolloServer.createHandler({ path: "/api/graphql" });
export default corsHandler((req, res) =>
req.method === "OPTIONS" ? res.end() : handler(req, res)
);
export default corsHandler(async (req, res) => {
const apolloServer = new ApolloServer({
schema: buildSubgraphSchema({ typeDefs, resolvers }),
dataSources,
apollo: {
graphId: "spaceapi",
graphVariant: "main",
},
});
await apolloServer.start();
const handler = apolloServer.createHandler({ path: "/api/graphql" });

req.method === "OPTIONS" ? res.end() : handler(req, res);
});
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
},
"dependencies": {
"@apollo/federation": "0.37.1",
"@apollo/subgraph": "2.1.3",
"@graphql-tools/load-files": "6.6.1",
"@graphql-tools/merge": "8.3.6",
"apollo-datasource": "0.10.0",
"apollo-server-micro": "2.26.0",
"apollo-server-micro": "3.10.3",
"csv-parse": "4.16.3",
"datasource-sql": "1.5.0",
"graphql": "16.6.0",
"micro": "9.4.1",
"micro-cors": "0.1.1",
"sqlite3": "5.1.2",
"typescript": "4.8.4",
"@graphql-tools/load-files": "6.6.1",
"@graphql-tools/merge": "8.3.6"
"typescript": "4.8.4"
},
"devDependencies": {
"@graphql-codegen/cli": "2.13.6",
Expand Down
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ type Query {
missions: [Mission]
}

scalar _FieldSet
scalar _FieldSet
Loading

1 comment on commit 10f9618

@vercel
Copy link

@vercel vercel bot commented on 10f9618 Oct 13, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.