Skip to content
This repository has been archived by the owner on Feb 15, 2023. It is now read-only.

Selection Sets Support #335

Open
Hale-ma opened this issue Nov 11, 2019 · 3 comments
Open

Selection Sets Support #335

Hale-ma opened this issue Nov 11, 2019 · 3 comments

Comments

@Hale-ma
Copy link

Hale-ma commented Nov 11, 2019

Hi, I enjoy using this library developing my graphql server. I would like to know is there any support for Selection Sets of query? Define different behavior in a function for query with different Selection Sets may enhance the performance. For instance, a query that only lookup a few field may only need a sample SQL to finish while looking for extra field for this fragment may need to have other logic to calculate the field to return . If I can pass the return field to my function, I can do different logic. However, seems query.FieldFunc("name",func) does not support this.

@kevinmichaelchen
Copy link

kevinmichaelchen commented Nov 7, 2020

Seems like related code: argsToJson and parseSelectionSet

thunder/graphql/parser.go

Lines 91 to 109 in babf75b

func argsToJson(input []*ast.Argument, vars map[string]interface{}) (map[string]interface{}, error) {
args := make(map[string]interface{})
for _, arg := range input {
name := arg.Name.Value
if _, found := args[name]; found {
return nil, NewClientError("duplicate arg")
}
value, err := valueToJson(arg.Value, vars)
if err != nil {
return nil, err
}
args[name] = value
}
return args, nil
}
// parseSelectionSet takes a grapqhl-go selection set and converts it to a
// simplified *SelectionSet, bindings vars
func parseSelectionSet(input *ast.SelectionSet, globalFragments map[string]*Fragment, vars map[string]interface{}) (*SelectionSet, error) {

@uripre
Copy link

uripre commented Mar 18, 2021

+1 for that

@uripre
Copy link

uripre commented Mar 18, 2021

Probably related to #200 and #201

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants