-
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v3 roadmap #72
Comments
And actually I don't like the syntax of I want to do like eventually: const query = gql`
query GetUsers {
user {
id: ${types.number}
name: ${types.string}
}
}
` However, the structure is apparently impossible without codegen. So I'm thinking what is the least verbose syntax. |
Hello @acro5piano I made a small library based in your library. Maybe it's a good idea to add these features to your library (or maybe not XD) |
Hi @albertcito ! |
Considering these hacks to omit expect(
mutation("BulkInsertUsers")({ $objects: "[user_insert_input!]!" })(q => {
q("insert_users")({ objects: "$objects" })({
returning: {
id: q.types.number
}
});
})
).toEqual(gql`
mutation BulkInsertUsers($objects: [user_insert_input!]!) {
insert_users(objects: $objects) {
returning {
id
}
}
}
`);
expect(
mutation("BulkInsertUsers")({
insert_users: {
returning: {
id: q.types.number
}
}
})
).toEqual(gql`
mutation BulkInsertUsers($objects: [user_insert_input!]!) {
insert_users(objects: $objects) {
returning {
id
}
}
}
`); |
typed-graphqlify looks very promising. I especially like that it doesn't try to be a client, but only a transformer for queries/mutation. In terms of querying API, I really liked this one: https://www.npmjs.com/package/graphql-typed-client As long as there is no code generation involved, it will be hard to allow for proper typing of input params and typed-graphqlify will be just half useful. Looking at projects like Hasura, input params can get very complex themselves and I'd like them to be type safe too. |
@bkniffler |
https://github.com/redux-model/graphql I'm watching your idea, and feel free to watch mine. import { types, graphql } from '@redux-model/graphql';
const tpl = graphql.query({
getUser: {
id: types.number, // number
name: types.string, // string
bankAccount: { // object
id: types.number,
branch: types.string.number, // string | number
},
logs: types.fn(['page_Int', 'size_Int'], types.array({
id: types.number,
title: types.null.undefined.string, // string | undefined | null
})),
}
});
type Response = typeof tpl.type;
const { query, variables } = tpl({
page_Int: 1,
size_Int: 10,
});
console.log(query);
// query GetUser ($page: Int, $size: Int) {
// getUser {
// id
// name
// bankAccount {
// id
// branch
// }
// logs (page: $page, size: $size) {
// id
// title
// }
// }
// }
console.log(variables);
// { page: 1, size: 10 } It's es5 based. No Symbol and Map |
By the way, I am using redux model which is base on redux. And I don't like apollo client. |
@fwh1990 |
Yep, its goal is saving people's life. And it will let people know that TS can be coding faster, not slower. |
I have been missing this syntax. We don't have to use mutation('BulkInsertUsers($objects: [user_insert_input!]!)', {
'insert_users(objects: $objects)': {
returning: {
id: types.number
}
}
}) mutation BulkInsertUsers($objects: [user_insert_input!]!) {
insert_users(objects: $objects) {
returning {
id
}
}
} This could be enabled by template literal types TS 4.1. |
v3 is released. |
I think typed-graphqlify could do more than the current type alias.
While I was working on Apollo and Apollo Codegen instead of typed-graphqlify, I feel it inconvenient in the following points:
__generated__
directoriesAnd typed-graphqlify lacks the following features:
And I would like to add a feature, requesting and type inference from query.
Currently we have to write
This is bothering, so if we can request like this:
This feature looks too much for this library, so I'm thinking splitting into other library though...
The text was updated successfully, but these errors were encountered: