graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.91k stars 839 forks source link

How do I change the schema based on the queries ? #210

Open challasrujanreddy opened 7 years ago

challasrujanreddy commented 7 years ago

If there is a graphQl schema which resolves it's queries by fetching data from a Mongodb, how can changes be made to the code so that even if there is a new field in the mongodb collections and user queries for it, that field is fetched from the database without throwing an error ?

chris-ramon commented 7 years ago

Hi @challasrujanreddy, thanks for using the lib and reaching us for a question:

sAbakumoff commented 7 years ago

And take a look at this awesome pull request : https://github.com/graphql-go/graphql/pull/195

challasrujanreddy commented 7 years ago

Thank you @chris-ramon and @sAbakumoff , I will sure check them out.

challasrujanreddy commented 7 years ago

@chris-ramon I went through the httpdynamic example that you shared. While I understood it, I am trying to figure out how we can deal with complex field types. In the example you shared what if there are nested fields in the schema and the fields are not simple string type. That is, we don't know the type of the field. For example, { "id": "1", "name": "Dan", "surname": "Jones", "age": { "before": "45", "after": "51", "now" : "48" } } In that case, you cannot use graphql.String type. @sAbakumoff I'd appreciate if you can share your thoughts. I am new to both graphql and golang, so sorry if the answer to my question is obvious.