graphql-compose/graphql-compose-json

Shallow?

azat-co opened this issue · 6 comments

Is this a shallow converter? I'm always getting JSON on nested types. It'll be nice to add some if/else in recursion to make this library to go deep.

nodkz commented

Its strange.
Should also create sub types.
See this lines

if (opts && opts.typeName && opts.fieldName) {

Can you provide a test case? Or even make PR (хватит книжки писать - сделай ПР, почему на holyjs не был)?

Right now I'm in Moscow. Will be at home via several days. But your changes may publish from mobile phone. 🤘

nodkz commented

PS. Also you may see my 300 slides for HolyJS and GraphQL Moscow Meetup https://github.com/nodkz/conf-talks/tree/master/holyjs-2018

Как ты смотришь на написание книжки по GraphQL в соавторстве?
https://github.com/nodkz/conf-talks/tree/master/articles/graphql

nodkz commented

@azat-co just added a test case for checking nested objects. And it properly creates Type for nested object.

const restApiResponse = {
title: 'A New Hope',
producer: {
name: 'Gary Kurtz, Rick McCallum',
},
};
const FilmTC = composeWithJson('FilmCustom', restApiResponse);
expect(FilmTC.getFieldTC('producer').getTypeName()).toBe('FilmCustom_Producer');
expect(FilmTC.getFieldTC('producer').getFieldNames()).toEqual(['name']);
expect(
FilmTC.getFieldTC('producer')
.getFieldType('name')
.toString()
).toBe('String');

Maybe you have another case which does not work for you?

У меня был JSON for nested types. Я могу посмотреть и про тестировать еще

По моему это возникало на 2 или 3 уровне вложенности

Еще не могу сделать строку из типа

const composeWithJson = require('graphql-compose-json').default;
const { print } = require('graphql/language/printer');
const {parse} = require('graphql');


const restApiResponse = require('./JobSearchResponseIndexResultsPage.gql')

const JobSearchResponse = composeWithJson('JobSearchResponse', restApiResponse);
const JobSearchResponseGQLType = JobSearchResponse.getType();
// console.log(print(parse(JobSearchResponse)));

Был где-то код но сейчас не могу найти. Это как?

nodkz commented

🎉 This issue has been resolved in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀