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

Documentation Explains "How" of Fragments ... But Not the "Why" #48

Open
machineghost opened this issue Dec 31, 2017 · 0 comments
Open

Comments

@machineghost
Copy link

machineghost commented Dec 31, 2017

The Lokka docs provide the following example of how to make and use a fragment:

const filmInfo = client.createFragment(`
  fragment on Film {
    title,
    director,
    releaseDate
  }
`);
client.query(`
  {
    allFilms {
      films {
        ...${filmInfo}
      }
    }
  }
`).then(result => {
  console.log(result.allFilms.films);
});

But you can do the same thing much more simply:

const filmInfo = `
    title,
    director,
    releaseDate`;
// The rest of the code remains the same except:
//        ...${filmInfo}
// becomes:
            ${filmInfo}

It's unclear to me what the benefit of using client.createFragment is. Even a sentence or two in the docs about that would be helpful.

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

1 participant