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

how to use nested object to make query? #55

Closed
dohooo opened this issue Feb 27, 2019 · 4 comments
Closed

how to use nested object to make query? #55

dohooo opened this issue Feb 27, 2019 · 4 comments

Comments

@dohooo
Copy link

dohooo commented Feb 27, 2019

No description provided.

@dohooo
Copy link
Author

dohooo commented Feb 27, 2019

    const games={
        gameName : types.string,
        location : types.string,
        gameTime : types.string,
        players : ???,
    }
    const player={
        name : types.string,        
        age : types.string,        
        joinGames: [games],
    }

The game struct contains player starct。。
How do I accomplish such a nested structure?

@dohooo
Copy link
Author

dohooo commented Feb 27, 2019

Maybe that doesn't make sense.. But I seem to have this problem

@luvies
Copy link
Collaborator

luvies commented Feb 27, 2019

GraphQL doesn't support recursive structures (see graphql/graphql-spec#91), so this library doesn't either. For that example, the best thing to do would probably be to move joinGames to a separate query, and have the GQL be

query ($playerId: ID!) {
  joinGames(playerId: $playerId) {
    gameName
    location
    gameTime
    players {
      name
      age
    }
  }
}

@dohooo
Copy link
Author

dohooo commented Feb 27, 2019

oh。 thx

@dohooo dohooo closed this as completed Feb 27, 2019
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

2 participants