xialvjun / tiny-graphql-client

a very simple and tiny graphql client, only support `query` and `mutation`.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support fragment?

yuu2lee4 opened this issue · comments

commented

support fragment?

it did support fragment. And it even support nested fragment...

const client = create_client(your_custom_send_function);
client.register_fragment(`
fragment person_fragment on Person {
  id, name, age
}`);
client.register_fragment(`
fragment book_fragment on Book {
  id, title, cover
  author { ...person_fragment }
}`);
client.run(`
query book($id: $ID!) {
  book(id: $id) { ...book_fragment }
}`, { id: '123456789' })
.then(r => r.json())
.then(r => console.log(r.data.book));
commented

恩 好谢谢 。。建议readme写上如何安装。。。还有就是把lib也传上来吧。。毕竟小程序原生开发 不能npm