Giter Site home page Giter Site logo

Comments (4)

OzzieOrca avatar OzzieOrca commented on May 21, 2024

I gave up using FraQL in the source code and am just using the normal gql from graphql-tag for fragments. I still wanted mocking so I'm using this helper function to pull the original query out, run it through FraQL's gql and generate mock data for it. Let me know if you know any cleaner ways to do this 😃

import {  IMocks } from 'graphql-tools';
import { DocumentNode } from 'graphql';
import gql from 'fraql';
import { createMockerFromIntrospection } from 'fraql/mock';

import introspectionQuery from '../schema.json';

import { globalMocks } from './globalMocks';

export const mockFragment = <TData>(
  fragmentDocument: DocumentNode,
  options?: {
    mocks: IMocks;
  },
): TData => {
  if (!fragmentDocument.loc) {
    throw 'Unable to get original gql query to create FraQL fragment.';
  }

  return createMockerFromIntrospection(introspectionQuery, {
    mocks: globalMocks,
  }).mockFragment(gql(fragmentDocument.loc.source.body), options);
};

from fraql.

gregberge avatar gregberge commented on May 21, 2024

FraQL has not evolve since a long time, it is probably the best choice to switch to graphql-tag.

Your way of mocking looks great, nothing to change here.

from fraql.

OzzieOrca avatar OzzieOrca commented on May 21, 2024

Oh gotcha. Have you seen fragment mocking features added to any other libraries? Maybe there's a way to do it with graphql-tools but it didn't seem immediately obvious. Thanks for the quick response and the update about the library 😄

from fraql.

gregberge avatar gregberge commented on May 21, 2024

I don't know if there is sorry!

from fraql.

Related Issues (7)

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.