graphql-python / graphql-core-legacy

GraphQL base implementation for Python (legacy version – see graphql-core for the current one)
MIT License
374 stars 183 forks source link

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

Closed yanghg-basefx closed 5 years ago

yanghg-basefx commented 5 years ago

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?