graphql-python / graphql-core-legacy

GraphQL base implementation for Python (legacy version – see graphql-core for the current one)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I try to write a relay-pyqt similar to relay-react, but there are some questions

yanghg-basefx opened this issue · comments

Here are test queries:

{
  foo {
    id
    name
  }
}
{
  foo {
    id
    type
  }
}

I want to merge these two queries. So I write a simple script:

query1 = parse('{foo{id name}}')
query2 = parse('{foo{id type}}')

type_field = query2.definitions[0].selection_set.selections[0].selection_set.selections[1]
query1.definitions[0].selection_set.selections[0].selection_set.selections.append(type_field)
query3 = parse(print_ast(query1))

So my questions are:

  1. I found though I append type_field to query1, the query Source are not changed. Will it affect any other thing?
  2. After I append type_field to query1, the query1 has been changed. Did you provide any function to copy Document? Or just use deepcopy directly?
  3. Did you provide any other helper function to merge two different query?