in Education by
I'm trying to query two JSON files that I put in a src/data directory. I installed gatsby-transformer-json and added the directory as a source. { resolve: `gatsby-source-filesystem`, options: { path: `${__dirname}/src/data/` } } I then tried several ways to build the graphql query but I am only able to successfully query the first json file I created work_experiences.json which looks like this although my second file skills.json has the exact same structure { "work_experiences": [ { "body": "lorem ipsum", "title": "lorem ipsum", "role": "lorem", "dateBegin": "2015-10-01", "dateEnd": "2016-07-03", "companyUrl": "http://www.lorem.com", "workUrl": "/lorem/ipsum/" }, ... A query on skills.json always returns null Is there a way to query both files or do I have to merge everything into a single data.json file ? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
If you have 2 files in the same root folder and will query, you will get data only from a single node, because dataJson queries into a single file. Or you use allDataJson like this: { allDataJson{ edges{ node{ work_experiences{ title } skills{ name } } } } } for a good solution, in this case, is to have your single-object json files stored in separate folders with just one json per folder. For example, you have some Users data: create a User folder in your src/data. create an index.json file with { "name": "blabla" }. query your data. Like this: { userJson{ name } }

Related questions

0 votes
    I'm trying to query two JSON files that I put in a src/data directory. I installed gatsby- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I am working in an graphql application where I have to send custom error object / message in json ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I am trying to fetch some data from the GitHub GraphQL but I get a GaphQLError. I have tried the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    I have huge JSON files in a folder approx 200 each of 300 mbs approx. I need to write Spring ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I have an graphql/apollo-server/graphql-yoga endpoint. This endpoint exposes data returned from a database ( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    How can I transform QraphQl query to HTTP get request for example http://localhost:4000/? query GetClient { ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm completely new in logging but familiar in SQL queries. I'm now experimenting with Serilog and Seq. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    What kind of files can be imported or exported using the COPY command (1)sstables (2)CSV (3)json (4)parquet...
asked Apr 17, 2021 in Technology by JackTerrance
0 votes
    The tables are: 1) Producers: id, name 2) Products: id, name, price, category_id, producer_id 3) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    Hi I'm using ffmpeg to concatenate several mp4 files that I downloaded. Usually they don't have the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    I want to change a couple of files at one time, iff I can write to all of them. I'm wondering if I ... to this problem look like? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    We have db collection which is little complicated. Many of our keys are JSON objects where fields aren't ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    This is a cURL function that can send or retrieve data. It should work with any PHP app that ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    What is the main difference between GraphQL and REST?...
asked Jun 13, 2021 in Education by Editorial Staff
0 votes
    I have multiple set of data to insert at once, say 4 rows. My table has three columns: Person, Id and ... a single SQL statement? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
...