3 ms·
Not sure what you mean...GraphQL is just the API endpoint. Using GQL or REST wouldn't make a difference on how suspense works. You'd still query and display yo
by bobobooey 7y ago
Not sure what you mean...GraphQL is just the API endpoint. Using GQL or REST wouldn't make a difference on how suspense works.
You'd still query and display your data in the same way. Suspense will just be a wrapper around the component displaying the data.
- choward 7y agoWith GraphQL you could in theory grab all the data a page needs in one request. Suspense seems to only be useful if you are making multiple requests. Not sure what Apollo has to do with anything though.
- bobobooey 7y agoIsn't still possible to wait for the data from that one request to be loaded? I'm also curious on how this will work with subscriptions.
- typon 7y agoConsider this code snippet using Apollo React Client: const Dogs = ({ onDogSelected }) => ( <Query query={GET_DOGS}> {({ loading, error, data }) => { if (loading) return 'Loading...'; if (error) return `Error! ${error.message}`; return ( <select name="dog" onChange={onDogSelected}> {data.dogs.map(dog => ( <option key={dog.id} value={dog.breed}> {dog.breed} </option> ))} </select> ); }} </Query> );
- bobobooey 7y agoYou could still wrap this in a suspense wrapper.