My framework uses Apollo Client to support OUT-OF-THE-BOX

I’ve created a new framework GitHub - babyfish-ct/graphql-ts-client: Typescript DSL for GraphQL.

This is a new GraphQL Client for TypeScript. it is integrated with @apollo/client since 2.1.4.

In the previous period, it was just some elegant TypeScript magic, unable to provide out-of-the-box services.

After a week of hard work, I finally integrated it with @apollo/client. With the support of @apollo/client, my framework finally provides out-of-the-box functionality, so it can also provide a step-by-step guide on the home page to tell users how to create simplest app. So cool

graphql-ts-client-small

Nice!

While this looks neat for sure, for me if I’m writing a lengthy query, it’s a lot easier to write the whole query as a separate file so that I can easily read the component itself.

I’d really like to see where this goes, though, because not having to run codegen all of the time even when the server has no schema updates would indeed be nice.

A few questions:

  • How does this handle aliases?
  • How do you select nested structures?
  • Can I write a query in one file, and import into multiple components with different variables?
    • Other than making a custom function, because that would effectively be the same amount of work to me as writing a query by hand.
  • Is there fragment support?
  • Does this project follow semantic versioning?

Q: How to handle alias
A: It generated useTypedQuery/useLazyTypedQuery, it’s first parameter is used to specify the alias(operation name and root field name), but multiple fetches in one request is not supported until now

Q: How to select nested structures?
A: I don’t understand, would’ u please say more clear? my english is not very good

Q: Can write in one file?
A: Yes, you can wait the strongly type fetcher as global exported constant. so that it can be shared everywhere. Actually, this is the suggested way because better performance

Q: Is there fragment support?
A: Yes, it’s is supported from 2.0.0, both inline-fragment and real fragment. The inline-fragment looks like relay compiler. it can automatically remove duplicated fields

Q: semantic versioning?
A: I don’t understand, would’ u please say more clear? my english is not very good

nested structures

query userIdsOfPost($id: ID!) {
  user(id: $id) {
    posts {
      likes {
        user {
          id
        }
      }
    }
  }
}

semantic versioning

OK, I don’t know it before, good spec. I will follow it in the future