graphql-go / graphql

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

[question] why don't support cache for AST & ValidateDocument #566

Open xpgg360 opened 4 years ago

xpgg360 commented 4 years ago

Because of the efficiency of reflect, Spend a lot of time in the "visitor" function. Why can't we support cache for this. do this like gqlgen or other

roelofjan-elsinga commented 4 years ago

I might be completely off, but isn't that what the DataLoader is for as mentioned in Third party plugins? gqlgen seems to use this method as well. Or am I missing something?

xpgg360 commented 4 years ago

I might be completely off, but isn't that what the DataLoader is for as mentioned in Third party plugins? gqlgen seems to use this method as well. Or am I missing something?

The purpose of cache can avoid to re-analyze AST & validateDoc each time when we send the same DSL query[ diffrent variable]. Moreover, the performance of validatedoc is very low and consumes a lot of CPU. Gqlgen supports the cache for AST / validataDoc. Dataloader is to solve the problem of N + 1, which is different from this one.