Giter Site home page Giter Site logo

fraql's People

Contributors

alex-mcleod avatar dependabot[bot] avatar gregberge avatar johman10 avatar petetnt avatar sdemjanenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fraql's Issues

Having trouble getting readFragment to work.

When using fraql 1.1.1 with readFragment it seems like the fragment in the graphql document cannot be found by apollo-client resulting in: Error: Found 0 fragments. fragmentName must be provided when there is not exactly 1 fragment.

Using graphql-tag works fine.

Let me know how I can help with investigation

Babel macro support

This library looks awesome!

Is there any chance of Babel macro support for build-time compilation? This would make fraql a drop-in replacement for graphql.macro as well, for (performant) use with create-react-app.

Can I pass variables into different fragment of components

This library is awesome, and I met a use case which are about the apollo variables.

I have more than two productByCode fragments inside different components,

eg:

fragment on Query { 
  shop {
    one: productByCode(codes: $codes) {
      id
      code
      title
      image
 	  price {
        amount
        currencyCode
      }
    }
  }
fragment on Query { 
  shop {
    two: productByCode(codes: $codes) {
      id
      badge
      image
    }
  }

How can inject the $codes variables from the top, which can be got by different fragments.

Exclude fields from fragment ?

Does the library support excluding some fields out of fragment ?
In my application, i generate fragments based on graphql schema, so it's a full-fields fragment.
In some cases, i just want to exclude some fields from generated fragments instead of duplicating it.

Benefits of fraql with vue?

It's not real issue, but I'm wondering whats benefits fraql bring to development instead of simply doing this below with Vue?

// App.vue
<template lang="html">
  <div class="apollo">
    <div v-if="$apollo.loading">Loading...</div>
    <div v-else-if="$apollo.error">Error :(</div>
    <RateCard v-else v-for="rate in rates" :key="rate.currency" :rate="rate" />
  </div>
</template>

<script>
import RateCard from './RateCard';
import gql from 'graphql-tag';
export default {
  components: {
    RateCard
  },
  apollo: {
    rates: gql`{
      rates(currency: "USD") {
        ${RateCard.fragments.rate}
      }
    }`,
  },
  data () {
    return {
      rates: '',
    }
  }
}
</script>
// RateCard.vue
<template>
  <div style="margin: 20px">
    <h2>{{rate.name}}</h2>
    <p>
      {{rate.currency}} - {{rate.rate}}
    </p>
  </div>
</template>

<script>
export default {
  props: {
    rate: Object
  },
  fragments: {
    rate: `
        name
        currency
        rate
    `,
  }
}
</script>

I'm just not using fraql :)
But my schema is closed to the template, and I can also pass variable to fragment and solve issue #10 !

Apollo codegen doesn't pick up FraQL fragment

Running apollo client:codegen --target typescript from apollo-tooling doesn't seem to pick up types from the fragment. Maybe this should be submitted in that repo but I was wondering if this is expected to work. Is this a static parsing issue? Can you think of any workarounds? Thanks 😃

Main component file:

import gql from 'fraql';

export const STEPS_QUERY = gql`
  query StepsList($after: String) {
    acceptedChallenges(after: $after, completed: false, first: 5) {
      nodes {
        id
        focus
        ${STEP_ITEM_QUERY}
      }
      pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
      }
    }
  }
`;

Child component file:

import gql from 'fraql';

export const STEP_ITEM_QUERY = gql`
  fragment _ on AcceptedChallenge {
    title
    receiver {
      id
      fullName
    }
  }
`;

Generated types for main component:

/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.

// ====================================================
// GraphQL query operation: StepsList
// ====================================================

export interface StepsList_acceptedChallenges_nodes {
  __typename: "AcceptedChallenge";
  id: string;
  focus: boolean;
}

export interface StepsList_acceptedChallenges_pageInfo {
  __typename: "PageInfo";
  /**
   * When paginating forwards, the cursor to continue.
   */
  endCursor: string | null;
  /**
   * When paginating forwards, are there more items?
   */
  hasNextPage: boolean;
  /**
   * When paginating backwards, are there more items?
   */
  hasPreviousPage: boolean;
  /**
   * When paginating backwards, the cursor to continue.
   */
  startCursor: string | null;
}

export interface StepsList_acceptedChallenges {
  __typename: "AcceptedChallengeConnection";
  /**
   * A list of nodes.
   */
  nodes: (StepsList_acceptedChallenges_nodes | null)[] | null;
  /**
   * Information to aid in pagination.
   */
  pageInfo: StepsList_acceptedChallenges_pageInfo;
}

export interface StepsList {
  /**
   * Find all accepted challenges for user
   */
  acceptedChallenges: StepsList_acceptedChallenges;
}

export interface StepsListVariables {
  after?: string | null;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.