Skip to content

Commit

Permalink
🐛 alias fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Apr 20, 2022
1 parent e709727 commit 230a019
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 259 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run produce-lib
- run: npm test
- run: npm run build
- run: npm publish --access public --tag latest
Expand Down
9 changes: 8 additions & 1 deletion examples/typescript-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ const run = async () => {
});
printQueryResult('drawChangeCard thunder', blalbaThunder.drawChangeCard);

const { listCards: stack, drawCard: newCard, drawChangeCard } = await Gql('query')({
const {
listCards: stack,
drawCard: newCard,
drawChangeCard,
} = await Gql('query')({
listCards: {
name: true,
cardImage: {
Expand Down Expand Up @@ -171,6 +175,9 @@ const run = async () => {
{
listCards: {
__alias: {
namy: {
name: true,
},
atak: {
attack: [
{ cardID: $('cardIds') },
Expand Down
18 changes: 9 additions & 9 deletions examples/typescript-node/src/zeus/apollo.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
/* eslint-disable */

import { Zeus, GraphQLTypes, InputType, ValueTypes, OperationOptions } from './index';
import { gql, useSubscription, useQuery, useLazyQuery, useMutation } from '@apollo/client';
import type { SubscriptionHookOptions, QueryHookOptions, LazyQueryHookOptions, MutationHookOptions } from '@apollo/client';
import { gql, useQuery, useLazyQuery, useMutation, useSubscription } from '@apollo/client';
import type { QueryHookOptions, LazyQueryHookOptions, MutationHookOptions, SubscriptionHookOptions } from '@apollo/client';


export function useTypedSubscription<Z extends ValueTypes[O], O extends "Subscription">(
subscription: Z | ValueTypes[O],
options?: SubscriptionHookOptions<InputType<GraphQLTypes[O], Z>>,
operationOptions?: OperationOptions,
) {
return useSubscription<InputType<GraphQLTypes[O], Z>>(gql(Zeus("subscription",subscription, operationOptions)), options);
}
export function useTypedQuery<Z extends ValueTypes[O], O extends "Query">(
query: Z | ValueTypes[O],
options?: QueryHookOptions<InputType<GraphQLTypes[O], Z>>,
Expand All @@ -33,3 +26,10 @@ export function useTypedMutation<Z extends ValueTypes[O], O extends "Mutation">(
) {
return useMutation<InputType<GraphQLTypes[O], Z>>(gql(Zeus("mutation",mutation, operationOptions)), options);
}
export function useTypedSubscription<Z extends ValueTypes[O], O extends "Subscription">(
subscription: Z | ValueTypes[O],
options?: SubscriptionHookOptions<InputType<GraphQLTypes[O], Z>>,
operationOptions?: OperationOptions,
) {
return useSubscription<InputType<GraphQLTypes[O], Z>>(gql(Zeus("subscription",subscription, operationOptions)), options);
}
72 changes: 36 additions & 36 deletions examples/typescript-node/src/zeus/const.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,29 @@
/* eslint-disable */

export const AllTypesProps: Record<string,any> = {
JSON: "String",
createCard:{
skills:"SpecialSkills"
},
Query:{
cardById:{

}
},
SpecialSkills: true,
JSON: "String",
Card:{
attack:{

}
},
Mutation:{
addCard:{
card:"createCard"
}
},
Card:{
attack:{

}
createCard:{
skills:"SpecialSkills"
}
}

export const ReturnTypes: Record<string,any> = {
S3Object:{
bucket:"String",
key:"String",
region:"String"
},
Subscription:{
deck:"Card"
},
SpecialCard:{
effect:"String",
name:"String"
},
EffectCard:{
effectSize:"Float",
name:"String"
},
Query:{
cardById:"Card",
drawCard:"Card",
Expand All @@ -48,24 +32,26 @@ export const ReturnTypes: Record<string,any> = {
myStacks:"CardStack",
nameables:"Nameable"
},
CardStack:{
cards:"Card",
name:"String"
},
S3Object:{
bucket:"String",
key:"String",
region:"String"
},
ChangeCard:{
"...on SpecialCard":"SpecialCard",
"...on EffectCard":"EffectCard"
},
Nameable:{
"...on SpecialCard": "SpecialCard",
"...on EffectCard": "EffectCard",
"...on CardStack": "CardStack",
"...on Card": "Card",
"...on SpecialCard": "SpecialCard",
"...on EffectCard": "EffectCard",
name:"String"
},
CardStack:{
cards:"Card",
name:"String"
},
Mutation:{
addCard:"Card"
},
Card:{
Attack:"Int",
Children:"Int",
Expand All @@ -78,11 +64,25 @@ export const ReturnTypes: Record<string,any> = {
info:"JSON",
name:"String",
skills:"SpecialSkills"
},
Mutation:{
addCard:"Card"
},
Subscription:{
deck:"Card"
},
SpecialCard:{
effect:"String",
name:"String"
},
EffectCard:{
effectSize:"Float",
name:"String"
}
}

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

0 comments on commit 230a019

Please sign in to comment.