frankcollins3 / PHPokedex

react concepts
0 stars 0 forks source link

GraphQL schema && object structure [11:52pm] #32

Open frankcollins3 opened 1 year ago

frankcollins3 commented 1 year ago

Screen Shot 2023-05-10 at 11 53 04 AM

Screen Shot 2023-05-10 at 11 53 23 AM

Screen Shot 2023-05-10 at 11 53 15 AM

scenario:

database pokedex. table pokemon: [moves] for now I have one piece of test data in the moves. I want to return the data as a list so that the array of possible moves for the corresponding pokemon can be stored as data. The data column must allow for many values.

In my test example though, because there is only one value, GraphQL List will not allow for the return of this one value while the GraphQL Type attributed to the query is expecting multiple values as a list does.

[11:57am]

frankcollins3 commented 1 year ago

this approach is not working:

Screen Shot 2023-05-10 at 12 00 42 PM

Screen Shot 2023-05-10 at 12 01 18 PM

Screen Shot 2023-05-10 at 12 00 58 PM

I believe the string will return if we leave the one value "tackle" from db to be used as pokemon.moves this doesn't help though if the end goal is to allow sets of data through the graphQL API

[12:02pm]

frankcollins3 commented 1 year ago

Screen Shot 2023-05-10 at 12 14 05 PM

I've added a string with some characters that precede ${obj.name} endpoint based value assignment. I also added a new pokemon/data into the database.

The database is returning the 2nd pokemon as well but is not returning the: { name: heres the: ${pokemon.name} }

its not rendering the updated string that includes the object and the "heres the" string concatenation.

[12:15pm]

frankcollins3 commented 1 year ago

const predata = await fetch(http://localhost:5000/pokemon?query={test{name,id}}) forgot that this the query within the fetch will assert the order of the endpoints returned from the object data (client)

[12:20pm]

frankcollins3 commented 1 year ago

Screen Shot 2023-05-10 at 12 22 19 PM

this code is still returning data which is confusing because there is no return data from the resolve: () =>

[12:22pm]

frankcollins3 commented 1 year ago

Im about to do a test by adding a new db item and seeing if it is returned

Screen Shot 2023-05-10 at 12 23 38 PM

Screen Shot 2023-05-10 at 12 24 10 PM

I'm now a bit confused because the graphQL is not updating with the types but is updating with the obj.name && obj.id

[12:24pm]

frankcollins3 commented 1 year ago

I dont need to restart the server to see the API/schema updating. I'm able to reverse the order of the data coming back.

Screen Shot 2023-05-10 at 12 25 14 PM

[12:25pm]