Open challasrujanreddy opened 7 years ago
Hi @challasrujanreddy, thanks for using the lib and reaching us for a question:
If the field does not exist in the schema, graphql validation will return an error complaining about that field, this is the way graphql works, for ensure query correctness.
If your looking for other solution different than manually adding new fields to the graphql schema, you might want to start exploring a solution where you create graphql schemas on runtime, we have an example you might want to take a look: https://github.com/graphql-go/graphql/tree/master/examples/httpdynamic
And take a look at this awesome pull request : https://github.com/graphql-go/graphql/pull/195
Thank you @chris-ramon and @sAbakumoff , I will sure check them out.
@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.
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 ?