Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template slice can only have 1 item, got 2 #158

Open
state-developer opened this issue Nov 7, 2024 · 0 comments
Open

template slice can only have 1 item, got 2 #158

state-developer opened this issue Nov 7, 2024 · 0 comments

Comments

@state-developer
Copy link

state-developer commented Nov 7, 2024

Have an object defined like this:

var StatusMutation struct {
     StatusCheck struct {
          ID graphql.ID `graphql:"id"`
          ... 
          StatusHistory []struct {
               Status string `graphql:"status"`
           } `graphql:"statusHistory"
     } `graphql:"statusCheck(input: $input)"`
}

Here is the mutation:

...
  statusMutationInput(input: $input){
      id,
      statusHistory{
        	... on SubmittedEvent{
                    status,            
            },
            ... on FinalizeEvent{
                    status,            
            }
          }
...

This works perfectly if only 1 item is passed into the StatusHistory. However, if I get more than 1, I get the template slice can only have 1 item, got 2 error above.

Here is the error (with debug):

template slice can only have 1 item, got 2, Locations: [], Extensions: map[code:graphql_decode_error internal:map[response:map[body:{\"data\":{\"statusCheck\":{\"id\":\"dHJhbnNhY3Rpb25fNmswaGNwenY\", ... ,\"statusHistory\":[{\"status\":\"SUBMITTED\"},{\"status\":\"FINALIZED\"}]}},\"extensions\":{\"requestId\":\"810d4903-6e2b-4d6c-a6d6-82cf5e33f80a\"}}

We can get 0, 1 or all of these events.

Not quite understanding why this is happening if I'm allowing for more than 1 item to be queried?

Thanks.

EDITED: Forgot to include mutation*

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

No branches or pull requests

1 participant