Skip to content

Commit

Permalink
Merge pull request #463 from thisismydesign/update-gql-zeus
Browse files Browse the repository at this point in the history
Update graphql-zeus
  • Loading branch information
thisismydesign authored Oct 26, 2023
2 parents 67f463a + 8afebd9 commit 64651eb
Show file tree
Hide file tree
Showing 6 changed files with 989 additions and 633 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"fishery": "^2.2.2",
"graphql-zeus": "^5.2.4",
"graphql-zeus": "^5.3.2",
"jest": "^28.1.3",
"prettier": "^2.8.1",
"supertest": "^6.3.3",
Expand Down
19 changes: 16 additions & 3 deletions src/client/app/apollo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,27 @@ const client = new ApolloClient({
cache: new InMemoryCache(),
});

export const context = (req: Request) => {
return { headers: { Cookie: req.headers.cookie } };
};

export const typedQuery = <Z extends ValueTypes[O], O extends 'Query'>(
query: Z | ValueTypes[O],
req: Request,
operationName?: string,
) => {
return client.query<InputType<GraphQLTypes[O], Z>>({
query: gql(Zeus('query', query, operationName)),
context: { headers: { Cookie: req.headers.cookie } },
query: gql(Zeus('query', query)),
context: context(req),
});
};

export const typedMutation = <Z extends ValueTypes[O], O extends 'Mutation'>(
mutation: Z | ValueTypes[O],
req: Request,
) => {
return client.mutate<InputType<GraphQLTypes[O], Z>>({
mutation: gql(Zeus('mutation', mutation)),
context: context(req),
});
};

Expand Down
28 changes: 0 additions & 28 deletions src/client/app/types/zeus/apollo.ts

This file was deleted.

21 changes: 8 additions & 13 deletions src/client/app/types/zeus/const.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
/* eslint-disable */

export const AllTypesProps: Record<string,any> = {
DateTime: "String",
DateTime: `scalar.DateTime` as const,
Mutation:{
createOrder:{
alias:{
type:"String",
array:false,
arrayRequired:false,
required:true
},
thingName:{
type:"String",
array:false,
arrayRequired:false,
required:true
}

}
}
}
Expand All @@ -31,6 +20,7 @@ export const ReturnTypes: Record<string,any> = {
created_at:"DateTime",
updated_at:"DateTime"
},
DateTime: `scalar.DateTime` as const,
Order:{
id:"Float",
alias:"String",
Expand All @@ -55,4 +45,9 @@ export const ReturnTypes: Record<string,any> = {
Mutation:{
createOrder:"Order"
}
}

export const Ops = {
query: "Query" as const,
mutation: "Mutation" as const
}
Loading

0 comments on commit 64651eb

Please sign in to comment.