import { DocumentNode, GraphQLSchema } from 'graphql'; /** Copyright 2021 Forestry.io Holdings, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ declare type FriendlyType = { __namespace?: string; name: string; } | string | string[]; declare const friendlyName: (field: FriendlyType, options?: { lowerCase?: boolean | undefined; suffix?: string | undefined; } | undefined) => string; declare const templateName: (string: string) => string; declare const templateTypeName: (template: FriendlyType, suffix: string, includeBody: boolean) => string; /** * * Given a valid GraphQL query,the `formify` will populate the query * with additional information needed by Tina on the frontend so we're able * to render a Tina form. * * ```graphql * query getPostsDocument($relativePath: String!) { * getPostsDocument(relativePath: $relativePath) { * data { * ... on Post_Doc_Data { * title * } * } * } * } * ``` * Would become: * ```graphql * query getPostsDocument($relativePath: String!) { * getPostsDocument(relativePath: $relativePath) { * data { * ... on Post_Doc_Data { * title * } * } * form { * __typename * ... on Post_Doc_Form { * label * name * fields { * # ... * } * } * } * values { * __typename * ... on Post_Doc_Values { * title * author * image * hashtags * _body * _template * } * } * sys { * filename * basename * breadcrumbs * path * relativePath * extension * } * } * } * ``` */ declare const formify: (query: DocumentNode, schema: GraphQLSchema) => DocumentNode; /** * The role of `splitQuery` is to look at a query and find all of the nodes * that could be returned by it, and to split that information into subsets of * the query's original graph. It returns the nodes being queried along with information * about what fragments they're using, how to query those nodes by themselves, and * finally how to mutate those nodes. * * The purpose of this is that while we represent our data as a Graph, it needs to be * delegated to our Tina form system, which is a lower-level API that has no knowledge * of our data needs, the form is focused solely on the task of submitting mutations for a * given document. */ declare const splitQuery: (args: { queryString: string; schema: GraphQLSchema; }) => { queries: { [key: string]: { query: string; mutation: string; path: (number | string)[]; fragments: string[]; }; }; fragments: { name: string; path: (string | number)[]; fragment: string; subFragments: string[]; }[]; }; /** * * This generates a query to a "reasonable" depth for the data key of a given collection * It's not meant for production use */ declare const queryGenerator: (variables: { relativePath: string; collection: string; }, schema: GraphQLSchema) => DocumentNode; export { formify, friendlyName, queryGenerator, splitQuery, templateName, templateTypeName };